简体   繁体   English

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

[英]NginX as HTTPS reverse proxy for multiple sub-domains?

I have one IP address on my Linux box, and would like to serve HTTPS websites in this form: 我的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

Each of these websites is a Docker container on the same host, so my idea were setting up an NginX reverse proxy Docker container. 这些网站中的每一个都是同一主机上的Docker容器,因此我的想法是设置NginX反向代理Docker容器。

There are many howto's about NginX as reverse proxy, but what I want to do is different from the text book example, as I have HTTPS, multiple sub-domains and multiple URL's. 关于NginX作为反向代理的方法有很多,但是我想做的事情与课本示例不同,因为我有HTTPS,多个子域和多个URL。

Questions 问题

Does anyone know of howto's that deal with this type of setup, or perhaps can tell me what the technical key words I should search for are? 有谁知道如何处理这种类型的设置,或者可以告诉我应该搜索哪些技术关键词?

At this point I don't know where to start, so any help will be much appreciated. 目前,我不知道从哪里开始,所以我们将不胜感激。

You need to add A-records to you DNS manager that will redirect all your subdomains to the IP address of the host machine. 您需要向DNS管理器中添加A记录,该记录会将您的所有子域重定向到主机的IP地址。 Then in your NGINX config you can do something like this. 然后,在您的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.

相关问题 在 unbuntu 和 nginx 上托管多个 ASP NET Core 站点作为反向代理 - Hosting multiple ASP NET Core sites on unbuntu and nginx as reverse proxy HAProxy和LXD容器-基于裸域,特定子域和所有其他子域的路由 - HAProxy and LXD Containers - Route based on naked domain, specific sub-domain and all other sub-domains Nginx作为运行Apache的反向代理 - nginx as reverse proxy for runining apache 将非 www 重定向到 www,但保持其他子域完好无损 - Redirecting non-www to www, but keeping other sub-domains intact Nginx 反向代理执行意外负载平衡 - Nginx reverse proxy does unexpected load balancing 在CentOS中使用Nginx作为Apache上Wordpress的反向代理 - Using Nginx as reverse proxy for wordpress on Apache in CentOS nginX-301从多个域重定向一个子域 - nginX - 301 Redirect a subdomain from multiple domains 如何使用 nginx 反向代理 SSH 到我的远程 docker 容器 - how to ssh to my remote docker containers using nginx reverse proxy 在特定情况下如何处理 Nginx 反向代理 502 错误? - How to handle Nginx reverse proxy 502 Error in specific case? Nginx代理在多个位置的多个服务器下 - Nginx Proxy under multiple locations multiple server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM