должно возвращаться HTTP/1.1 301 Moved Permanently
, в котором пользовательский агент может или не может перенаправить на новое место.
используйте -L
или --location
в вашей команде curl для автоматического следования перенаправлениям.
Изменить 2018-07-05:
Вот основные конфигурации в nginx.conf:
Хотя это не плохая конфигурация, использование директивы if
не рекомендуется .
Вам лучше разбить конфигурацию на два отдельных блока server
, один для http, а другой для https.
Что-то вроде:
server {
listen 80;
server_name example.com;
# log your http request if you need to
error_log /var/log/nginx/example-com_error.log notice;
access_log /var/log/nginx/example-com_access.log combined;
# certbot endpoint
location ~ ^/\.well-known/ {
root /var/www/certbot/;
access_log off;
}
# other requests should end up here
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name example.com;
# log your http request if you need to
error_log /var/log/nginx/example-com_error.log notice;
access_log /var/log/nginx/example-com_access.log combined;
# default document root and document index
root /var/www/html;
index index.html;
# SSL cert, private key, and configurations.
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# https configurations
location / {
proxy_pass http://127.0.0.1:80; # why would you proxy_pass back to nginx again?
# you only need this if your proxy_pass uses https, not http like this example.
proxy_ssl_trusted_certificate /etc/letsencrypt/live/example.com/cert.pem;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
}
}
должно хватить.
Когда я запускаю curl -iI https://example.com,, возвращается:
да, почему бы не вернуть HTTP/1.1 200 OK
?
Небезопасная часть флага --insecure
только в cURL отключает проверку сертификата HTTPS , то есть вы можете использовать недопустимый сертификат SSL в запросе HTTPS (плохой CN, плохой SAN, неправильный срок действия, плохой CA, самоподписанный и т. д.) и cURL все равно удовлетворит ваш запрос, вместо того, чтобы терпеть неудачу.