nginx 反向代理配置,nginx代理配置


nginx常用命令

启动: start nginx
重启: nginx -s reload
关闭: nginx -s stop

nginx反向代理配置

    server {
        listen       80;                            #监听的端口
        server_name  m.testa.com;                   #监听请求来自m.testa域名的
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {                                #请求是来自根目录的 / eg:来自http://m.testa.com都会请求到http://127.0.0.1:8081 服务器
                proxy_pass    http://127.0.0.1:8081;#目标服务器
                proxy_redirect default;
        }
    }
    server {
        listen       80;            #监听的端口
        server_name  pc.testb.com;  #监听请求来自pc.testb域名的
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location /api/ {            #请求是来自目录的 /api/ 到 192.100.201.22:9081服务器
            proxy_pass    http://192.100.201.22:9081/;
            proxy_redirect default ;
        }
        location / {                #请求是来自目录的 / 127.0.0.1:8080 服务器
            proxy_pass    http://127.0.0.1:8080;
            proxy_redirect default;
        }
    }

相关内容

    暂无相关文章