Nginx 代理和 nuxtjs 没有连接

Nginx proxy and nuxtjs is not connected

我安装了 nginx 和 nuxtjs,但它只在浏览器私有模式下加载

nuxtjs 运行 port:8081

这是我的配置:

server {
        listen       8080 default_server;
        listen       localhost:8080 default_server;
        server_name  _;

        location / {
                proxy_pass http://localhost:8081;
                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;
        }

如果你的 Nuxtjs 是 8081 端口上的负载,那么你的 Nginx 配置如下所示:

map $sent_http_content_type $expires {
    "text/html"                 epoch;
    "text/html; charset=utf-8"  epoch;
    default                     off;
}

server {
    listen          80;             # the port nginx is listening on
    server_name     your-domain;    # setup your domain here

    gzip            on;
    gzip_types      text/plain application/xml text/css application/javascript;
    gzip_min_length 1000;

    location / {
        expires $expires;

        proxy_redirect                      off;
        proxy_set_header Host               $host;
        proxy_set_header X-Real-IP          $remote_addr;
        proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto  $scheme;
        proxy_read_timeout          1m;
        proxy_connect_timeout       1m;
        proxy_pass                          http://localhost:8081; # set the address of the Node.js instance here
    }
}

更多信息请访问官方文档: https://nuxtjs.org/faq/nginx-proxy/