Welcome! Log In Create A New Profile

Advanced

reverse proxy multiple subdomains problems

Posted by c0mputerking 
c0mputerking
reverse proxy multiple subdomains problems
September 03, 2018 10:10PM
I am trying to do a redirect from http and a reverse proxy to my apache web
server. I would like to include several subdomains, they all have dns
records and apache virtual hosts setup on the other end. However no matter
which of the 3 subdomains i try i always end up at https://my-site.com this
is fine for www.my-site.com but recipes.my-site.com is a supposed to be a
different website all together.

I am new with nginx and have a hunch that it may have something to do with
$server_name$request_uri not being the right option in my case but i'm not
sure see config below

server {
listen 172.16.0.10:80;
server_name my-site.com www.my-site.com recipes.my-site.com;
return 301 https://$server_name$request_uri;
}

server {
listen 172.16.0.10:443 ssl;

server_name my-site.com www.my-site.com recipes.my-site.com;

access_log /var/log/nginx/van-ginneken.com-access.log;
ssl_certificate /root/SYNC-certs/van-ginneken.com/fullchain.pem;
ssl_certificate_key /root/SYNC-certs/van-ginneken.com/privkey.pem;

set $upstream 172.16.0.13;

location / {
proxy_pass_header Authorization;
proxy_pass https://$upstream;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
proxy_redirect off;
proxy_ssl_session_reuse off;
}
}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,281086,281086#msg-281086

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Francis Daly
Re: reverse proxy multiple subdomains problems
September 04, 2018 09:10AM
On Mon, Sep 03, 2018 at 04:07:49PM -0400, c0mputerking wrote:

Hi there,

> I am new with nginx and have a hunch that it may have something to do with
> $server_name$request_uri not being the right option in my case but i'm not
> sure see config below

Correct.

You probably want $host instead of $server_name.

http://nginx.org/r/$server_name
http://nginx.org/r/$host

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login