You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署在Nginx的Django应用:跳转Shopify链接被重定向回域名如何解决?

Nginx配置导致Shopify跳转链接被强制重定向回www.example.com

我在注册Certbot证书时操作失误,仅为www.example.com完成注册,未同时包含example.com。因此我在Nginx配置里强制所有请求指向www.example.com以完成部署,但现在点击跳转至Shopify店铺的链接时,该链接会直接被重定向回www.example.com。

以下是我的nginx.conf配置文件:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 4096;
        # multi_accept on;
}


http {
        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;
        include /etc/nginx/mime.types;
        default_type application/octet-stream;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers on;
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        gzip on;

    server {
            listen 80;
            return 444;
    }
    server {
            server_name www.example.com, example.com;
            listen 80;
            return 307 https://www.example.com$request_uri;
    }
    server {
        listen [::]:443 ssl ipv6only=on; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        server_name www.example.com;
        ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem; # managed by Certbot
       ssl_certificate_key /etc/letsencrypt/live/www.example.com/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

            location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.;
                  proxy_pass http://unix:/run/gunicorn.sock;                            
                  proxy_set_header        Host $host;
                  proxy_set_header X-Forwarded-Proto $scheme;
                  proxy_set_header X-Forwarded_For $proxy_add_x_forwarded_for;
                  proxy_redirect off;
            }
            location /static/ {
                    autoindex on;
                    alias /var/www/www.example.com/static/;
        }
    }
}

我尝试过修改监听端口、调整请求头、移除部分配置项,但至今没有效果。当前配置对我的Gunicorn运行来说是理想状态,希望有人能指出问题所在。

内容的提问来源于stack exchange,提问作者ReliableAirRepair

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 22:04:56