1

I am going to implement a nginx reverse proxy. There are two servers in heroku, one named myapp.herokuapp.com and the other named blog.herokuapp.com. The domain is www.mydomain.com and it links to my nginx server. In nginx server the redirect rules is below: www.mydomain.com links to myapp.herokuapp.com and www.mydomain.com/* would link myapp.herokuapp.com/* But when customer goes to www.mydomain.com/blog and www.mydomain.com/blog/* will link to blog.herokuapp.com and blog.herokuapp.com/*.

Is it possible to implement with nginx reverse proxy? and do you have any ideas about that?

Currently I can redirect from 80 to 443

server{
    listen 80;
    server_name www.mydomain.com mydomain.com;
    return 301 https://$host$request_uri;
}
server{
    listen 443;
    server_name www.mydomain.com mydomain.com;
    location /{
        (how to change the location rules?)
    }
}
Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58
cccc
  • 23
  • 4

1 Answers1

2

You can have the following location blocks:

location ~ /blog(/.+)$ {
    proxy_pass http://blog.herokuapp.com$1;
}

location / {
    proxy_pass http://myapp.herokuapp.com;
}
Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58