【问题标题】:deploy nextjs with nginx with 403 forbidden使用禁止 403 的 nginx 部署 nextjs
【发布时间】:2023-01-12 06:12:12
【问题描述】:

我使用 nextjs 作为前端,使用 django 作为后端

在开发阶段一切正常

但在生产中 raise /_next/static/chunks ... 403 Forbidden Error

我的 nginx 配置不能正常工作

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        server_name <server_name> <www.server_name>;

        index index.html index.htm index.nginx-debian.html;     
        root /{my_dir}/client/.next/;

        location /static {

                proxy_pass http://localhost:3000;

                # For testing cache - remove before deploying to production
                # add_header X-Cache-Status $upstream_cache_status;
        }
        location /_next/static {

                #proxy_cache STATIC;
                proxy_pass http://localhost:3000;

                # For testing cache - remove before deploying to production
        # add_header X-Cache-Status $upstream_cache_status;
        }
        location / {
                proxy_pass http://localhost:3000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        }


}

我尝试了不同的 nginx 配置

  • 谁能帮帮我?

【问题讨论】:

    标签: javascript node.js reactjs nginx next.js


    【解决方案1】:

    尝试为您的网站配置 ssl (https)

    这是一个免费给你证书的网站:https://certbot.eff.org/

    【讨论】:

      猜你喜欢
      • 2013-03-05
      • 2023-02-23
      • 2017-02-24
      • 2018-12-17
      • 2019-06-07
      • 2019-04-17
      • 2016-04-23
      • 2021-01-30
      相关资源
      最近更新 更多