【问题标题】:Nginx proxy and nuxtjs is not connectedNginx代理和nuxtjs没有连接
【发布时间】:2019-10-31 08:09:31
【问题描述】:

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

nuxtjs 在端口: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;
        }

【问题讨论】:

    标签: nginx centos nuxt.js


    【解决方案1】:

    如果你的 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/

    【讨论】:

      猜你喜欢
      • 2020-08-21
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多