如何为SSL配置NuxtJS?

时间:2019-08-28 12:02:57

标签: ssl nginx vuejs2 nuxt.js cloudflare

早上好, 如何为SSL +套接字正确配置nuxtjs

当我指向nuxt.config.js

server: {
  host: '0.0.0.0',
  port: 3000
}

和nginx

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

server {
    listen 443;

    server_name    domain.ru;    # setup your domain here

    ssl on;

    ssl_certificate /root/cert/domain.crt;

    ssl_certificate_key /root/cert/domain.key;

    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                          https://127.0.0.1:3000; # set the adress of the Node.js instance here
    }
}

更重要的是,位于proxy_pass中的是https 除套接字外,该站点工作正常,但如果配置不同,则错误502总是会爬出

0 个答案:

没有答案