<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">Hi there<br><br>try this<br><br>http {<br> upstream myapp1 {<br> server 192.168.16.201;<br> server 192.168.16.202;<br> server 192.168.16.203;<br> server 192.168.16.204;<br> }<br> server {<br> listen 80;<br> location / {<br> proxy_pass http://myapp1/;<br> proxy_set_header Host $host;<br> #proxy_redirect https://myapp1/ http://$host/;<br> }<br> }<br>}<br><br>Basically "<strong>proxy_set_header Host $host;</strong>" is passing the host name as seen by nginx to the upstream servers, so any redirect originating at upstream will redirect to the same host which it was called with. without this statement upstream servers sees host name as myapp1 which nginx uses to request them.<br><br>If this one doesn't work as expected you might like to un-comment "#proxy_redirect <a target="_blank" tabindex="-1" rel="external nofollow" href="https://myapp1/">https://myapp1</a> http://$host/;" line, although in my opinion it wont be necessary.<br><br><br>Regards<br>Pratyush Kumar<br><a target="_blank" href="http://erpratyush.me">http://erpratyush.me</a><br>live and let live go vegan<br><br>July 9 2016 9:56 PM, "Francis Daly" <<a target="_blank" href="mailto:francis@daoine.org">francis@daoine.org</a>> wrote:<blockquote>On Sat, Jul 09, 2016 at 11:23:41AM -0400, bai030805 wrote:<br><br>Hi there,<br> <blockquote>Nginx IP: 192.168.16.206<br>Four Web Server: 192.168.16.201-204</blockquote><br><br>Is there one Host: header that you can send in requests to each of the<br>four web servers, so that they will all return the content that you want?<br><br>If so, use that. If not, send none. That is...<br> <blockquote>location / {<br>proxy_pass <a target="_blank" href="http://myapp1">http://myapp1</a>;</blockquote><br><br>nginx will make a request of the upstream server including "Host: myapp1".<br><br>You can change that by using "proxy_set_header Host" with your preferred<br>name. (Or you can use that name instead of "myapp1" here, and in the<br>"upstream" definition.)<br><br>Possibly<br><br>proxy_set_header Host "";<br><br>is what you want here.<br><br>Depending on what your upstream servers send, you may need more config<br>in nginx to get everything to work the way that you want it to.<br> <blockquote>}<br><br>}<br><br>from web brower, i use http://192.168.16.206 to access the web server. the<br>web brower redirect "http://192.168.16.206" to "<a target="_blank" href="https://myapp1">https://myapp1</a>"</blockquote><br><br>If there really is a switch from http to https, that suggests that<br>something extra is happening.<br><br>What response do you get from<br><br>curl -v -H Host:myapp1 http://192.168.16.201/<br><br>? Because that is more-or-less the request than nginx makes.<br><br>Good luck with it,<br><br>f<br>--<br>Francis Daly <a target="_blank" href="mailto:francis@daoine.org">francis@daoine.org</a><br><br>_______________________________________________<br>nginx mailing list<br><a target="_blank" href="mailto:nginx@nginx.org">nginx@nginx.org</a><br><a target="_blank" href="http://mailman.nginx.org/mailman/listinfo/nginx">http://mailman.nginx.org/mailman/listinfo/nginx</a></blockquote></div></body></html>