nginx proxy_pass configuration to virtualhost

Tim Spencer | Spacesharing GmbH t.spencer at spacesharing.eu
Sun Dec 21 13:10:18 UTC 2014


On 21/12/14 11:31, mex wrote:
> Hi tim,
>
>> Hi,
>>
>> I would like to redirect to an external URL which is hosted as a
>> apache
>> virtual host.
> redirect or proxy_pass? correct wording is important here
>
preferred proxy_pass

>> nginx resolves the host of the url which obviously does little to
>> resolve to the correct web root on the server.
> i dont understand what you mean here. if nginx doesnt resolve a dns-name
> how should it know how to deal with it? dns-names are for humans.
yeah the issue does not seem to be on my side, I have have no issue of 
nginx resolving the ip but it seems that the hosting company I would 
like to proxy_pass to has the virtual hosts configured on the dns names
>
>> |  server {
>>               server_name localhost;
>>               location / {
>>                       proxy_set_header Host $host;
>>                       proxy_pass http://www.urlforvirtualhost.com;
>>               }
>>       }
>> |
>>
>> The question is how do I allow proxy_pass without nginx resolving the
>> ip-address of the host?
> but why dont you want nginx to resolve the IP?
>
>
> i'm not sure this will  work as expected, except you put in the ip.
> but then the apache on the other side should be configred
> with the ip in the virtualhost
generally I concur but how would they be able to, in est multiple sites 
on the same public ip but differentiate on dns names (this is also 
achievable on nginx) with the default directing to nowhere.

this would probably mean proxy_pass to a host configured to serve 
multiple pages as following

http  <http://wiki.nginx.org/NginxHttpCoreModule#http>  {
   index  <http://wiki.nginx.org/NginxHttpCoreModule#index>  index  <http://wiki.nginx.org/NginxHttpCoreModule#index>.html;
  
   server  <http://wiki.nginx.org/NginxHttpCoreModule#server>  {
     server_name  <http://wiki.nginx.org/NginxHttpCoreModule#server_name>  www.domain1.com;
     access_log  <http://wiki.nginx.org/NginxHttpLogModule#access_log>  logs/domain1.access.log main;
  
     root  <http://wiki.nginx.org/NginxHttpCoreModule#root>  /var/www/domain1.com/htdocs;
   }
  
   server  <http://wiki.nginx.org/NginxHttpCoreModule#server>  {
     server_name  <http://wiki.nginx.org/NginxHttpCoreModule#server_name>  www.domain2.com;
     access_log  <http://wiki.nginx.org/NginxHttpLogModule#access_log>   logs/domain2.access.log main;
  
     root  <http://wiki.nginx.org/NginxHttpCoreModule#root>  /var/www/domain2.com/htdocs;
   }
}

would not work. I presumed there was a option to force nginx to not resolve but I can see now this is probably not the case and I would need to change to redirect instead of proxy_pass.


>
>
> cheers, mex
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,255696,255704#msg-255704
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20141221/5251d989/attachment.html>


More information about the nginx mailing list