【问题标题】:How to config NGINX reverse proxy and let's encrypt certificate如何配置 NGINX 反向代理并加密证书
【发布时间】:2018-07-15 18:46:20
【问题描述】:

我已将 Nginx 服务器设置为 Python/WSGI Web 应用程序的反向代理。这是启用站点的配置文件:

server {
    listen 80;
    server_name mydomain.com;

    location = /favicon.ico { access_log off; log_not_found off; }

    location / {
        include     uwsgi_params;
        uwsgi_pass  unix:/home/user/webapp/webapp.sock;
    }

我可以将 certbot 用于一个设置,其中 Nginx 不是反向代理,它的工作原理很吸引人,但是在上面的配置中,当我运行 certbot 时出现以下错误:"Could not automatically find a matching server block for mydomain.com. Set theserver_namedirective to use the Nginx installer"。根据1 的说法,它看起来像是 Nginx 的错误配置。我基于此answer 创建了证书,但我不知道如何配置 nginx 以使用此新证书接受 https,而它是反向代理。

【问题讨论】:

    标签: nginx reverse-proxy lets-encrypt


    【解决方案1】:

    这个配置对我有用:

    server {
        listen 80 default_server;
    
        listen 443 ssl;
        server_name mydomain.com www.mydomain.com;
    
        ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
    
        ssl_stapling on;
        ssl_stapling_verify on;
    
        access_log /var/log/nginx/nginxSSL.log combined;
    
        location = /favicon.ico { access_log off; log_not_found off; }
    
        location / {
            include     uwsgi_params;
            uwsgi_pass  unix:/home/user/webapp/webapp.sock;
        }
    }
    

    ~

    【讨论】:

      猜你喜欢
      • 2017-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-19
      • 1970-01-01
      • 2017-08-14
      相关资源
      最近更新 更多