gpt4 book ai didi

linux - NginX 作为多个子域的 HTTPS 反向代理?

转载 作者:太空宇宙 更新时间:2023-11-04 10:39:59 25 4
gpt4 key购买 nike

我的 Linux 机器上有一个 IP 地址,我想以这种形式为 HTTPS 网站提供服务:

https://landing.example.com

https://site-01.example.com/index.html
https://site-01.example.com/files/index.html
https://site-01.example.com/store/index.html

https://site-02.example.com/index.html
https://site-02.example.com/files/index.html
https://site-02.example.com/store/index.html

这些网站中的每一个都是同一主机上的 Docker 容器,所以我的想法是设置一个 NginX 反向代理 Docker 容器。

有很多关于 NginX 作为反向代理的 howto,但我想做的与教科书示例不同,因为我有 HTTPS、多个子域和多个 URL。

问题

有谁知道处理此类设置的方法,或者可以告诉我应该搜索的技术关键词是什么?

在这一点上我不知道从哪里开始,所以任何帮助将不胜感激。

最佳答案

您需要向您的 DNS 管理器添加 A 记录,它将您的所有子域重定向到主机的 IP 地址。然后在您的 NGINX 配置中,您可以执行类似的操作。

server {
listen 80;
server_name landing.example.com;
location /static {
alias /home/example-dir/staticfiles;
}
access_log /home/example-dir/nginx-access.log;
error_log /home/example-dir/nginx-error.log info;
}
server {
listen 80;
server_name site-01.example.com;
location /static {
alias /home/example-dir2/staticfiles;
}
}

关于linux - NginX 作为多个子域的 HTTPS 反向代理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35558010/

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