Reputation: 496
I have a nginx server and I have a domain listening on port 80. I also want to setup if a user enters the ip address of the server they get this static html page.
Right now my ip address server block which is
listen XXX.XXX.XXX.XXX:80
is overriding the domain server block how can I fix this? I tried using default_server but I thinking that putting an if statement would be the best. Any ideas are appreciated.
Upvotes: 0
Views: 49
Reputation: 14354
Don't confuse listen
directive with server_name
.
listen
is network level directive which makes nginx listen to some port and interface, while server_name
is about what Host
header will browser send.
So instead of listen 12.34.56.78:80
you should use
listen 80;
server_name 12.34.56.78;
Also it's worth to read how nginx process request.
Upvotes: 1