繁体   English   中英

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作为反向代理的方法有很多,但是我想做的事情与课本示例不同,因为我有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;
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM