gpt4 book ai didi

ssl - 域中的 www 无法正常工作 - nginx

转载 作者:太空宇宙 更新时间:2023-11-03 15:13:26 25 4
gpt4 key购买 nike

当您包含 www.在网址中。

mydomain.com --> Working but www.mydomain.com --> Not Working

配置文件:

server {
listen 80;
listen [::]:80;
#server_name git.mydomain.com;
return 301 https://$host$request_uri;
}

server {
listen 443 default_server ssl;
listen [::]:443 default_server ssl;
server_name git.www.mydomain.com;
# certs sent to the client in SERVER HELLO are concatenated in ssl_certific$
ssl_certificate /etc/nginx/ssl/mydomain.com.crt;
ssl_certificate_key /etc/nginx/ssl/mydomain.com.key;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;

# Diffie-Hellman parameter for DHE ciphersuites, recommended 4096 bits
ssl_dhparam /etc/nginx/ssl/dhparam.pem;

# modern configuration. tweak to your needs.
ssl_protocols TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDH$
ssl_prefer_server_ciphers on;

# HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
add_header Strict-Transport-Security max-age=15768000;

location / {
try_files $uri $uri/ =404;
}
}

你能帮帮我吗?谢谢!

最佳答案

您需要设置您希望 Nginx 提供服务的服务器名称。

server {
listen 80;
listen [::]:80;
server_name mydomain.com www.mydomain.com;
return 301 https://$host$request_uri;
}

所以你列出了你想要用空格分隔的名字。 我假设您想使用您在 https 配置中设置的服务器名称将所有 www 和非 www 流量重定向到 https,并且您的 https 服务器名称是正确的。

关于ssl - 域中的 www 无法正常工作 - nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43735374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com