Nginx with default_server and multiple domains on one ipaddress -


i have freshly installed nginx , created new configuration test.example.com. works.

but example.org points server. if go example.org nginx redirects me test.example.com.

i've read need create default server entry , e.g. return 444; did. configuration site:

server {     listen       ip:80;     server_name test.example.com;     server_tokens off;     root /nowhere;     rewrite ^ https://test.example.com$request_uri permanent; } server {     listen ip:443;     server_name test.example.com;     server_tokens off;     root [...];  [...] } 

the default server entry added in nginx.conf before (also tried after) "include /etc/nginx/sites-enabled/*;"

server {     # use default instead nginx 0.7.x, default_server 0.8.x+     listen ip:80 default_server;            server_name _;     return 444; } 

for me looks correct. still redirected example.org test.example.com.

you shouldn't have server_name set @ in default one. need before actual server block in nginx config.

also 444 weird error return. should return 404 indicate server not found, rather custom nginx error code.

edit

as ssl not working, don't appear have set ssl certificates in config file or turned ssl on.

server {     listen 443 default_server ssl;     ssl_certificate      /usr/local/nginx/conf/cert.pem;     ssl_certificate_key  /usr/local/nginx/conf/cert.key;        server_name test.example.com;     server_tokens off;     root [...]; } 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -