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

时间:2016-02-22 15:52:21

标签: linux nginx https docker reverse-proxy

我的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作为反向代理的方法,但我想做的是与教科书示例不同,因为我有HTTPS,多个子域和多个URL。

问题

有没有人知道如何处理这种类型的设置,或者可能告诉我应该搜索的技术关键词是什么?

此时我不知道从哪里开始,所以任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

您需要向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;
    }
}
相关问题