Nginx URL masking to a different domain

后端 未结 2 523
野性不改
野性不改 2020-12-25 08:59

There\'s a few similar questions on SO, but none exactly mine, and I\'ve had no luck trying to adapt their answers so far.

I want to map the URL http://sub.exa

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-25 09:19

    server {
        listen 80;
        server_name sub.example.com;
    
        location / {
            proxy_pass https://123.12.12.12/path;
        }
    }
    

    Thats how it works. If proxy_pass contains locations part - current location will be replaced to specified. http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

    But it's help only for http request and http redirects. If application create html with links https://123.12.12.12 - it's still unchanged. In this case you can try ngx_http_sub_module.

提交回复
热议问题