代码之家  ›  专栏  ›  技术社区  ›  Thomas Carlton

如何编写Nginx反向代理?

  •  0
  • Thomas Carlton  · 技术社区  · 5 年前

    我在Ubuntu上安装了nginx

    我想提供以下几页:

    • 案例A:当URL以ORD开头(不区分大小写)时,应提供以下URL: 本地主机:8443/ords
    • 案例B:否则,应提供以下url: localhost:8443/something:

    例如,案例A:

    案例B

    我尝试了以下配置,但不起作用。

    • 我打字的时候 www.example。com/ords 我得到的只有案例B: localhost:8443/ords/something:ords (在我期待案例A时: 本地主机:8443/ords )

    谁能帮忙吗?

        server {
                listen 443 ssl;
                server_name example.com www.example.com;
                
                location = /ords {
                                proxy_set_header Host $host;
                                proxy_pass https://localhost:8443/ords;                             
                                }
                            
                location / {
                            proxy_set_header Host $host;
                            proxy_pass https://localhost:8443/ords/something:;
                                }                               
        }
    
    0 回复  |  直到 5 年前