买的阿里云服务器部署博客学习,做到升级 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;
}
}
}