我无法为我的Nginx服务器获得正确的配置。 我使用Certbot来配置SSL。我制作了一个在localhost:3000上运行的节点服务器。我可以使用http访问服务器(我使用proxy_pass),但是我想使用SSL。我找到了如何生成证书(https://letsencrypt.org/docs/certificates-for-localhost/),但是我不知道要在nginx配置中进行哪些更改才能在本地主机上使用它。有什么帮助吗? :)这是我的配置:
upstream api {
server localhost:3000;
}
server {
server_name example.com;
root /home/ubuntu/dev/example.com;
index index.html;
try_files $uri $uri/ /index.html;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
# managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf;
# managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# managed by Certbot
location /api/v1 {
proxy_pass https://api;
rewrite ^/api/v1/?(.*) /$1 break;
}
}
server {
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name example.com;
return 404; # managed by Certbot
}