Nginx работает с http, но не с https. вернуть ERR_CONNECTION_TIMED_OUT - PullRequest
0 голосов
/ 12 октября 2019

Я использую certbot для создания SSL для моего сайта и использую Nginx для подачи. Однако, даже если я изменю блок сервера в nginx conf и перезапущу его, только оригинальная работа http, но https вернет ERR_CONNECTION_TIMED_OUT.

Я пробовал много способов в Интернете, включая разделение блока сервера на два, отрегулируйте настройку прослушивания 443, добавьте имя_сервера ... но все они, кажется, не работают, использование URL с https вернет ERR_CONNECTION_TIMED_OUT.

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    listen 443 ssl;
    listen [::]:443 ssl ipv6only=on;
    ssl_certificate     /etc/letsencrypt/live/myasshole.club/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/myasshole.club/privkey.pem;

    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name www.example.com;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            proxy_pass http://localhost:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #       include snippets/fastcgi-php.conf;
    #
    #       # With php7.0-cgi alone:
    #       fastcgi_pass 127.0.0.1:9000;
    #       # With php7.0-fpm:
    #       fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #       deny all;
    #}

}

есть ли желание включитьhttps в nginx? Я уверен, что ключ pem работает, и я думаю, что проблема в моей настройке конфигурации ...

1 Ответ

0 голосов
/ 12 октября 2019

Попробуйте это

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    listen 443 ssl;
    listen [::]:443 ssl;
    ssl on;
    ssl_certificate     /etc/letsencrypt/live/myasshole.club/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/myasshole.club/privkey.pem;

    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name www.example.com;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            proxy_pass http://localhost:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #       include snippets/fastcgi-php.conf;
    #
    #       # With php7.0-cgi alone:
    #       fastcgi_pass 127.0.0.1:9000;
    #       # With php7.0-fpm:
    #       fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #       deny all;
    #}

}

Также обратите внимание, что лучше добавить свой домен сюда server_name www.example.com example.com; Затем перезапустите nginx sudo service nginx restart

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...