Nginx未将url连接到应用程序



这是我的nginx站点启用文件。

server {
client_max_body_size 4G;
server_name example.in;

gzip on;
gzip_proxied any;
gzip_vary on;
gzip_types application/javascript application/json text/css text/xml;
gzip_comp_level 4;

location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}

listen 443 ssl http2; # managed by Certbot
listen [::]:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/example.in/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.in/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
server_name example.in www.example.in;
return 301 https://example.in$request_uri;
}

当我访问时,example.in网站正在正常打开。然而,当我打开www.example.in时,我会得到默认的nginx页面。这种配置有什么问题?我对其他域有相同的配置,这很好。

nginx-T给出以下结果:

nginx: [warn] conflicting server name "www.example.in" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.example.in" on [::]:80, ignored
nginx: [warn] conflicting server name "example.in" on [::]:443, ignored
nginx: [warn] conflicting server name "www.example.in" on [::]:443, ignored
nginx: [warn] conflicting server name "example.in" on 0.0.0.0:443, ignored
nginx: [warn] conflicting server name "www.example.in" on 0.0.0.0:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

您的配置看起来是正确的。检查是否有任何其他nginx配置文件在启用的站点下启用。通常,名称为"default"的默认文件是使用默认服务器配置启用的,这可能会导致问题。检查该文件是否也包含www.example.in的条目。如果是这种情况,请禁用它或将文件设为空白。

最新更新