当我浏览到我的wordpress网站时,它会自动重定向到https。
然而,我得到一个大的TTFB,我相信这可能是由于一个基本的配置错误。
目前,我有以下配置(HTTPS仍然工作,但我不明白)
server {
listen 8080 ;
listen [::]:8080 ;
port_in_redirect off;
absolute_redirect off;
...如果我做了以下更新
server {
listen 443 ssl;
listen [::]:443 ssl ;
port_in_redirect off;
absolute_redirect off;该网站不再可访问。
当服务器首先监听8080时,SSL是如何工作的?我的配置中没有301
编辑:完整配置-下面这个版本以某种方式将所有流量正确地重定向到https://
server {
listen 8080 ;
listen [::]:8080 ;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
large_client_header_buffers 4 64k;
proxy_max_temp_file_size 0;
root /home/site/wwwroot;
index index.php index.html index.htm;
server_name domain.co.uk www.domain.co.uk;
access_log off;
error_log off;
port_in_redirect off;
absolute_redirect off;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /html/;
}
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types image/svg+xml image/x-icon text/plain text/html text/xml text/css text/javascript application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript application/x-font-ttf application/vnd.ms-fontobject font/opentype font/ttf font/eot font/otf image/vnd.microsoft.icon;
location ~* \.(eot|ttf|woff|woff2|webmanifest)$ {
add_header Access-Control-Allow-Origin *;
}
location ~* \.(css|js|ico|gif|jpeg|jpg|webp|png|svg|eot|otf|woff|woff2|ttf|ogg)$ {
expires max;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 3600;
fastcgi_read_timeout 3600;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}发布于 2021-11-24 05:35:21
在端口8080上,它是在没有SSL的情况下工作,是纯文本。对于添加SSL,仅仅将listen 8080转换为listen 443 ssl是不够的。您还需要至少添加指定证书链和服务器私钥的行:
listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to/privkey.pem;完整链是PEM表单中所有证书的简单连接(它是文本文件,里面有Base64 64编码的数据),第一个证书是服务器对应于私钥的证书,然后是它的直接颁发者CA,等等,直到但不包括根CA。
如果证书中有几个名称(现代证书总是使用subjectAlternativeNames,它允许指定多个域名),则由您在server_name选项中指定它们。您可以只指定证书SAN字段中存在的服务器名称,但不需要使用所有这些名称。(如果您指定SAN字段中存在的其他内容,您的客户端将显示一个SSL证书错误,当他们以该名称访问您的服务器时,它不属于某个域。)在您的情况下,证书必须至少对domain.co.uk和www.domain.co.uk都有效。
详情请参见手册。如果您使用certbot ( ACME客户端)和nginx安装插件来获得证书,它将自动配置所有内容。如果您是“手工”获得证书,则必须手动添加这些配置选项。
https://serverfault.com/questions/1084330
复制相似问题