How to make nginx only respond to one domain?
Posted
by
larryzhao
on Server Fault
See other posts from Server Fault
or by larryzhao
Published on 2012-03-23T07:34:36Z
Indexed on
2012/03/23
11:31 UTC
Read the original article
Hit count: 238
I am pretty new to nginx, I host my rails application on nginx+passenger. I want my website to be accessible to only one domain. So I set my nginx conf like the following:
server {
listen 80;
server_name mydomain.com www.mydomain.com;
root /var/deploy/myapp/current/public;
passenger_enabled on;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
add_header Cache-Control public;
}
}
I specify the server_name
directive, but still, it answers anything which points to this IP and I could see that in the access.log that it answers to other domain names.
Is there anything I am doing wrong?
© Server Fault or respective owner