Reputation: 2948
I have a server with nginx listening to port 80 and has configs for several domain names, connections to which should be proxied to different ports.
Here are my config files:
domain1
#This is for redirecting everyone from www.domain.com to domain.com
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name www.domain1.com;
return 301 $scheme://domain1.com$request_uri;
}
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name domain1.com;
location / {
proxy_pass http://localhost:8081/;
proxy_set_header X-Real-IP $remote_addr;
}
}
domain2
#This is for redirecting everyone from www.domain.com to domain.com
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name www.domain2.com;
return 301 $scheme://domain2.com$request_uri;
}
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name domain2.com;
location / {
proxy_pass http://localhost:8090/;
proxy_set_header X-Real-IP $remote_addr;
}
}
domain3
#This is for redirecting everyone from www.domain.com to domain.com
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name www.domain3.com;
return 301 $scheme://domain3.com$request_uri;
}
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name domain3.com;
location / {
proxy_pass http://localhost:8091/;
proxy_set_header X-Real-IP $remote_addr;
}
}
All these config files are (as usual) located in /etc/nginx/sites-available/
and symlinked to /etc/nginx/sites-enabled/
When i added first file everything worked as a charm, when i added second file it is the same, after adding third file nginx stopped giving me any messages when i try to do service nginx reload
or service nginx restart
or service nginx start
.
It responds to service nginx stop
and service nginx status
. Apparently these functions work, but other functions in these preconditions are not responding and do not do anything. The output below is just copy-paste from my console.
# service nginx status
[ ok ] nginx is running.
# service nginx reload
# service nginx restart
# service nginx stop
[ ok ] Stopping nginx: nginx.
# service nginx start
# service nginx status
[FAIL] nginx is not running ... failed!
#
If i remove symlink to the third file everything works perfectly again.
So here is the question -- is it something wrong with my setup? or my logic? or with nginx?
The environment is:
- Debian Squeeze x64
- Nginx version 1.2.6
Upvotes: 2
Views: 2923
Reputation: 10546
the symptoms you're having indicate that your nginx config with the 3th file is incorrect, which is why the reload is failing
The output of nginx -t
should tell you where in your config the problem is.
Upvotes: 1