I'm trying to configure nginx as a reverse proxy for two websites on the same server. This is what I'm doing:
upstream alpha { server localhost:49212; } server { listen 80; server_name alpha.example.com; location / { proxy_pass http://alpha; } } upstream beta { server localhost:49213; } server { listen 80; server_name beta.example.com; location / { proxy_pass http://beta; } } server { listen 80; server_name ""; return 444; } It starts and doesn't complain about anything. Then, when I open alpha.example.com or beta.example.com - I always end up at http://localhost:49212. Moreover, no matter what URL I open on port 80, http://localhost:49212 is rendered.
This is not what I'd expect. I want only http://alpha.example.com to be redirected/proxied to http://localhost:49212 and nothing else. Looks like nginx doesn't pay attention to the Host HTTP header and just redirects everything to the first upstream.
What is wrong?
server_name