V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
jiguojun31
V2EX  ›  2018

网站转 https 失败,证书已获取但是 nginx 配置改了一天一直不对

  •  
  •   jiguojun31 · 2018-03-06 18:01:34 +08:00 · 2215 次点击
    这是一个创建于 2454 天前的主题,其中的信息可能已经有所发展或是发生改变。

    买的阿里云服务器部署博客学习,做到升级 https 时遇到了困难。 系统:centos 项目: koa2 + vue + mongodb ssl 工具用的 certbot 申请的证书,已获取保存在服务器上,但是似乎配置 nginx.conf 时出了问题。 小白一枚不懂 nginx,之前都是照着网上的资料配的,求教- -

    nginx.conf 代码

    events {
        worker_connections 1024;
    }
    
    http {
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    
        access_log  /var/log/nginx/access.log  main;
    
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
    
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
    
            ssl_trusted_certificate "/etc/letsen#        ssl_session_cache shared:SSL:1m        include /etc/nginx/conf.d/*.conf;
        server {
            listen       80 default_server;
            listen       [::]:80 default_server;
            server_name  www.jiguojun.com;
                proxy_set_header Connection "";
                proxy_set_header X-NginX-Proxy true;
                proxy_set_header Host   $http_host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Real-IP  $remote_addr;
            location / {
            server_name  www.jiguojun.com;
            root         /usr/share/nginx/html
    
            include /etc/nginx/default.d/*.conf;
        
            location / {
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host   $http_host;
                proxy_set_header X-NginX-Proxy true;
                proxy_set_header Connection "";
                proxy_http_version 1.1;
                proxy_pass http://127.0.0.1:3001;
            }
    
            location ^~ /.well-known/acme-challenge/ {
                default_type "text/plain";
                root     /usr/share/nginx/html;
            }
        }
        
        # Settings for a TLS enabled server.
        server {
            listen       443 ssl http2;
            listen       [::]:443 ssl http2;
            server_name  www.jiguojun.com;
            ssl          on;
            root         /usr/share/nginx/html;
    
            ssl_certificate "/etc/letsencrypt/live/www.jiguojun.com/fullchain.pem";
            ssl_certificate_key "/etc/letsencrypt/live/www.jiguojun.com/privkey.pem";
            
            include /etc/nginx/default.d/*.conf;
    
            location / {
                proxy_pass http://127.0.0.1:3001;
            }
        }
    
    }
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1237 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:09 · PVG 02:09 · LAX 10:09 · JFK 13:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.