美文网首页
nginx配置前端部署

nginx配置前端部署

作者: 掐指化梦 | 来源:发表于2020-08-31 09:11 被阅读0次

    nginx.conf 配置
    1.配置访问权限
    user root;
    2.配置返回文件content-type
    引入 mime.types
    include /ext/nginx/conf/mime.types;
    3.配置server
    listen 80; //监听端口号
    server_name localhost; //本机可以换成域名 www.domain.com
    location / 用来监听的路径
    alias /home/html; 静态文件路径
    root /home/html; 静态文件路径
    alias 和 root 的却别
    location /web/
    alias /home/html;
    访问的是 /home/html/web
    root /home/html;
    访问的是 /home/html;
    代理直接使用
    location ^~/api{
    proxy_pass http://api.server.com
    }

    完整配置

    user root;
    
    worker_processes 1;
    
    events {
        worker_connections 1024;
    }
    
    http {
        include /ext/nginx/conf/mime.types;
        server {
            listen        8080;
            server_name   localhost;
            location / {
                  alias   /home/html;
                  index  index.html;
                  location ^~/api {
                          proxy_pass http://api.server.com
                  }
            }
        }
    }
    

    相关文章

      网友评论

          本文标题:nginx配置前端部署

          本文链接:https://www.haomeiwen.com/subject/oozysktx.html