Unable to map upstream with folder in nginx server

孤街醉人 提交于 2019-12-11 01:57:46

问题


I want to map our system port 82 with 127.0.0.1:8080/runningSite and I am gettting exception with nginx config.

 upstream dev {
            server 127.0.0.1:8080/runningSite;
    }
server {
    rewrite_log on;
    listen [::]:81;
    server_name localhost;

    location / {
        proxy_pass  http://dev;
        proxy_set_header  Host $http_host;          
    }

    }

Exception :

nginx: [emerg] invalid host in upstream "127.0.0.1:8080/runningSite" in C:\nginx -1.8.1/conf/nginx.conf:85

Can anyone please help me where I am wrong.


回答1:


You can use location like this

location / {
      proxy_pass http://ttbth/home;
      proxy_set_header  Host $http_host;
    }



回答2:


You have the URI in the wrong place. It needs to go in the proxy_pass and not in the upstream block.

Try this:

upstream dev {
    server 127.0.0.1:8080;
}
server {
    rewrite_log on;
    listen [::]:81;
    server_name localhost;

    location / {
        proxy_pass  http://dev/runningSite/;
        proxy_set_header  Host $http_host;          
    }
}

See this document for details.



来源:https://stackoverflow.com/questions/35914245/unable-to-map-upstream-with-folder-in-nginx-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!