类型:https://example.com =>ssl ok但类型:www.example.com和example.com是httpno redirecthttps.(www重定向到非www)。
WordPress地址(URL)和站点地址(URL):https//example.com
/etc/nginx/conf.d/example.com.conf
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name example.com www.example.com;
ssl on;
ssl_certificate /etc/nginx/ssl/cert_chain.crt;
#ssl_CACertificate_File /etc/nginx/ssl/example.com.ca-bundle;
ssl_certificate_key /etc/nginx/ssl/example.com.key;
access_log off;
# access_log /home/example.com/logs/access_log;
error_log off;
# error_log /home/example.com/logs/error.log;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
root /home/example.com/public_html;
include /etc/nginx/conf/ddos2.conf;
index index.php index.html index.htm;
server_name example.com;
字符串
怎么修?抱歉我英语不好,谢谢。
7条答案
按热度按时间x6yk4ghg1#
这可能是由于服务器名称不明确造成的。请尝试使用以下命令:
字符串
你可以通过运行
sudo nginx -t
来检查你的nginx配置。gmol16392#
我也遇到过类似的问题。这是由Linux防火墙引起的(端口80被禁止)。
kg7wmglp3#
您的配置不清楚,您在末尾有一个重复的
server_name example.com
行。尝试使用这个:
字符串
h7appiyu4#
更新此行返回301 https://$server_name$request_uri;
返回301 https://$http_host$request_uri
brc7rcf05#
我也有同样的问题与nginx,所以我应用这些服务器只接受一个请求,这将决定为http和https
字符串
通过使用这个,我只有服务器块来处理任何请求
ygya80vv6#
如果您的域设置位于
字符串
或者你可以在/etc/nginx/sites-available/domain.com上为每个域名设置不同的文件。
型
vkc1a9a27#
这段代码将帮助你重定向到https:
假设您输入http://www.example.com,则它将重定向到https://www.example.com
,如果有人输入http:example.com,它将重定向到https://www.example.com
字符串