NginX 作为多个子域的 HTTPS 反向代理?
NginX as HTTPS reverse proxy for multiple sub-domains?
我的 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 盒子上有一个 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;
}
}