How to make nginx only respond to one domain?
- by larryzhao
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?