Nginx 未将 url 连接到应用程序

Nginx not connecting url to application

这是我的 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

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