I have an nginx 1.4.5 server running on an AWS EC2 instance. I have two conf file: the default.conf and myapp.conf. The default.conf listen to localhost, and myapp.conf listen to myapp.mydomain.com.
However I found even I type in myapp.mydomain.com in the browser, it always load the default.conf. I've changed the log_format in nginx.conf file add a "$server_name" field to check the server name of each request. I found it's always localhost.
Any one has any idea about this?
Updates with configuration info
the nginx.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
...
}
The myapp.conf
server {
listen 80;
server_name myapp.mydomain.com;
access_log /var/log/nginx/myapp.log;
location / {
add_header P3P 'CP="CAO PSA OUR"';
proxy_pass http://127.0.0.1:8080/myapp/;
set $ssl off;
if ($scheme = https) {
set $ssl on;
}
proxy_set_header X-Forwarded-Ssl $ssl;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
And yes I am behind two firewalls, one is iptable, the other one is AWS built in secure group
Someone with a similar problem got it fixed by:
I've fixed this now, in case anyone has the same problem as me it was to do with "
server_names_hash_bucket_size 64;" in/etc/nginx/nginx.conf.That line was commented out by default so I uncommented and restarted nginx and it works fine now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With