天天看點

Nginx反向代理關鍵配置

欲通過​

​127.0.0.1:8811​

​​(代理伺服器)來通路​

​127.0.0.1:8080​

​​位址上的(真實)伺服器,需要如下配置,非常關鍵,摘錄​

​nginx.conf​

​中的關鍵配置以供讀者參考。不同作業系統上配置都大體相同。

server {
        listen       8811;
        server_name  127.0.0.1;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
            proxy_pass http://127.0.0.1:8080;
            # proxy_pass http://www.baidu.com; # page goes to Baidu while visiting 127.0.0.1:8811
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }      

令附一個比較全面的​​ 參考​​。

繼續閱讀