1. 程式人生 > >nginx根據專案名實現內網地址轉發

nginx根據專案名實現內網地址轉發

nginx根據訪問的專案名進行內網地址轉發

以下是nginx的配置資訊:

server {
        listen       8081;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
      #匹配以訪問的專案名跳轉到對應的內網地址
        location /huwj {
            proxy_pass http://127.0.0.1:8002/huwj;
        }
      #跳轉到test專案
        location /test {
            proxy_pass http://127.0.0.1:8083/;
        }
        #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;
        }