Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I map some exact remote URL to the local one with different port

Long story short: We have remote dev server. Which contains several Symfony2 instances. Like example.com/page1 and example.com/page2 are different AWS instances with different applications. One of those (i.e. /page1) is my responsibility. And I am able to develop it remotely and locally. Obviously locally is fastest way, but there're list of reasons why it's better to develop remotely when whole applications work at once under similar domain. So I want to make example.com/page1 to refer to my local instance, so I don't send files via FTP every Cmd+S.

From Apache settings I can map some local URL to the Remote one, doing it with ProxyPass

ProxyPass /app/ http://example.com/app/

What I need, is exactly the same, but vice versa.

I have two the same web applications running remotely and locally.

Remote: https://example.com:33333/app/

Local: http://localhost:22222/app/

I need to get it work in this way:

  • https://example.com:33333/homepage/ -> https://example.com:33333/homepage/
  • https://example.com:33333/app/ -> http://localhost:22222/app/

Keeping the remote URL in Browser address bar.

Is that possible to set it up on my end (not from ProxyPass on remote side)

Probably some Chrome Extension, or Proxy Application?

like image 947
Maksym Avatar asked Feb 01 '16 21:02

Maksym


1 Answers

It's not as simple as that, and it's completely different from proxy pass.

When user types 'example.com' in their browser - browser decides where to send the request, your nginx configuration has no effect whatsoever. Browser will, however, use DNS to make the decision and you can interfere with that.

If you have control over users DNS - you could overwrite example.com domain so that requests come to your local server instead. If it's your local machine only, you could do it in /etc/hosts. After that, it's as simple as adding example.com in server_name tag in the nginx configuration.

Another possibility is configuring the router but I assume it's not an option for you.

like image 180
Denis Mysenko Avatar answered Oct 13 '22 16:10

Denis Mysenko