0

here is my nginx config for port 80.

location / {
        rewrite ^ https://$host$request_uri? permanent;
    }

    location /admin {
        rewrite ^ https://$host:7000$request_uri permanent;
    }

what I want is when user types http://mywebsite.com/admin , url has to become https://mywebsite.com:7000. the thing is url doesn't change internally and it also gets changed in browser. How do I do that so browser url doesn't get changed?

2

What you want is a Reverse Proxy.

Try this:

location / {
        rewrite ^ https://$host$request_uri? permanent;
    }

    location /admin {
        proxy_pass https://localhost:7000;
    }

If your service running on non-ssl port, then use http://localhost:7000; instead.

14
  • Thanks,but when I used this, it doesn't load the js/css files at all and says 404 not found . – Nika Kurashvili May 5 '19 at 12:58
  • @NikaKhurashvili: think you have to add a / after the port: proxy_pass https://localhost:7000/. – Thomas May 5 '19 at 13:00
  • I added it. still not working. – Nika Kurashvili May 5 '19 at 13:01
  • @NikaKhurashvili: then check your nginx logfiles at /var/log/nginx or wherever you have configured your logs to go to. – Thomas May 5 '19 at 13:12
  • 1
    From where? Port 80 or from port 7000? Please give examples for the URLs that are not working with full path. Or do you want to map /admin to https://localhost:7000/admin instead? – Freddy May 5 '19 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.