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;
        }
    }



令附一个比较全面的 参考





作者:艾孜尔江

posted @ 2021-02-17 19:21  艾孜尔江  阅读(131)  评论(0编辑  收藏  举报