G
G
gremlintv22019-03-21 13:17:47
Nginx
gremlintv2, 2019-03-21 13:17:47

Is it possible in NGINX to proxy a mirror to a specific url (subdomain.domain.com -> domain.com/subdomain)?

Is it possible to proxy a mirror to a specific url in NGINX:
subdomain.domain.com => domain.com/subdomain
I.e. without changing the address bar in the browser
Thank you

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2019-03-21
@gremlintv2

nginx.org/ru/docs/http/ngx_http_proxy_module.html#...

server {
    listen 80;
    server_name  subdomain.domain.com;

    location / {
        proxy_pass http://domain.com/subdomain/;
    }
}

G
gremlintv2, 2019-03-21
@gremlintv2

I found a solution for myself:

server {
    listen 80;
    server_name  subdomain.domain.com; 
    
    location  / {
               rewrite ^/$ /subdomain/$1 break;
               proxy_pass         http://127.0.0.1:8080;
               proxy_set_header   Host $host;
               proxy_redirect     off;
      }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question