0

currently I have my main website running in a droplet. My domain https://example.com has an A record pointing to the ip of the droplet and in the droplet I'm using nginx-proxy with the VIRTUAL_HOST variable of the domain.

Now, I would like to access one whole different application hosted in another droplet through the url https://example.com/myapp

I know I could use the same logic above using a subdomain https://myapp.example.com pointing to the ip of this new droplet, but I really would like to use the url https://example.com/myapp

How can I accomplish this? Is that possible at all?

Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
Falcoa
  • 117
  • 1
  • Giving negative points without any feedback is not helpful, at least say something to explain how stupid is the question. Thanks – Falcoa Feb 07 '19 at 06:13
  • 1
    Yes, you would use a reverse proxy such as Nginx or HAProxy. One of those apps receive the request then send it on to the application to service the request. I've upvoted your question back to zero as I think it's a perfectly reasonable question. – Tim Feb 07 '19 at 07:39

1 Answers1

1

You would use the "reverse proxy" functionality of the Nginx http_proxy_module on the server handling your domain example.com to map the URL path "/myapp" to the second droplet.

In its most simple form that is with the proxy_pass directive:

location /myapp/ {
     proxy_pass http://ip-or-hostname-of-other-droplet/myapp/;
}

but depending on the internal functionality of your app you may need to use one or more of the additional directives the module provides or jump though even more hoops to get the application to work correctly.

MadHatter
  • 78,442
  • 20
  • 178
  • 229
HBruijn
  • 72,524
  • 21
  • 127
  • 192