More than one host

Anoop Alias anoopalias01 at gmail.com
Mon May 6 12:15:54 UTC 2019


Try

proxy_set_header   Host   $host;

On Mon, May 6, 2019 at 5:15 PM Julian Brown <julian at jlbprof.com> wrote:

> I am having a problem and not sure which side of the ocean it is on (Nginx
> or Apache).
>
> I am internally setting up an Nginx reverse proxy that will eventually go
> public.
>
> I have two domains I want Nginx to proxy for, both go to different
> machines.
>
> The second domain is for a bugzilla host, bugzilla.conf:
>
> server {
>     server_name bugzilla.example.com;
>
>     listen *:80;
>
>         access_log /var/log/nginx/bugzilla.access.log;
>         error_log /var/log/nginx/bugzilla.error.log debug;
>
>     location / {
>         proxy_set_header X-Real-IP  $remote_addr;
>         proxy_set_header X-Forwarded-For $remote_addr;
>         proxy_set_header Host bugzilla.example.com;
>         proxy_pass https://INTERNAL_IP <https://internal_ip/>/;
>     }
> }
>
> It does send the request to the correct machine, but I do not know if it
> is sending the correct hostname or not.
>
> On the machine I am sending to is an Apache instance with multiple
> development versions of our server and bugzilla.   The request is getting
> handled by what is apparently the default vhost of the Apache server, not
> the bugzilla vhost.  In other words the wrong data is being sent out
> because it is going to the wrong end point on Apache.
>
> In the log for that vhost on Apache I see:
>
>   1 192.168.1.249 - - [05/May/2019:14:43:28 -0500] "GET /bugzilla/
> HTTP/1.0" 200 4250 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64)
> AppleWebKit/537.36 (KHT
>   2 Execution Time 8579
>
> the dash after 200 4250 is the 'host" I believe it is seeing or defaulting
> to "-" and not http://bugzilla.example.com.
>
> In my Nginx config I set proxy_set_header Host to what I want it to send
> as bugzilla.example.com, but I am not sure what is getting sent.
>
> Is proxy_set_header Host, the proper way to send it as "
> bugzilla.example.com" so that Apache sees it coming on that server name
> to activate the correct vhost?
>
> It could be a problem in the Apache vhost config, but if I direct my
> browser with /etc/hosts directly at Apache it works correctly it is only
> with proxying from Nginx that I see this behavior.
>
> Any comments?
>
> Thanx
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx



-- 
*Anoop P Alias*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20190506/b6950765/attachment.html>


More information about the nginx mailing list