gpt4 book ai didi

ssl - Nginx 配置文件 : Redirect from HTTP subdomain to HTTPS port

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

我是 Nginx 的新手,我已经在端口 8000 上使用 Ajenti 进行了全新安装。

我希望在 Ajenti 有一个子域点,它是 HTTPS,但不在网站的其他任何地方使用 HTTPS。所以所有这些事情都会发生:

http://domain1.co.uk

http://sub.domain1.co.uk -> https://sub.domain1.co.uk

https://sub.domain1.co.uk -> https://domain1.co.uk:8000

我已经达到了:

http {
index index.html;

ssl_certificate common.crt;
ssl_certificate_key common.key;

server {
listen 80;
server_name www.domain1.co.uk;
access_log logs/domain1.access.log main;

root /var/www/domain1.co.uk/htdocs;
}
server {
listen 80;
server_name sub.domain1.co.uk;

location / {
proxy_pass https://127.0.0.1:8000/;
proxy_set_header Host $host;
proxy_buffering off;
}
}
}

离我有多远?

提前致谢

马赫

最佳答案

如果我没理解错的话,应该是:

http {
index index.html;

ssl_certificate common.crt;
ssl_certificate_key common.key;

# Redirect http://sub.domain1.co.uk to https://sub.domain1.co.uk
server {
listen 80;
server_name sub.domain1.co.uk;

return 301 https://sub.domain1.co.uk;
}
# Proxy pass https://sub.domain1.co.uk to http://127.0.0.1:8000/
server {
listen 443;
server_name https://sub.domain1.co.uk;
location / {
proxy_pass http://127.0.0.1:8000/;
proxy_set_header Host $host;
proxy_buffering off;
}
}
# http://domain1.co.uk & www.domain1.co.uk
server {
listen 80;
server_name domain1.co.uk
www.domain1.co.uk;
access_log logs/domain1.access.log main;

root /var/www/domain1.co.uk/htdocs;
}
}

关于ssl - Nginx 配置文件 : Redirect from HTTP subdomain to HTTPS port,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21255320/

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