Can I map the exact remote url to local with another port

In short: We have a remote server. Which contains several instances of Symfony2. For example, 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 can develop it remotely and locally. Obviously, locally this is the fastest way, but there is a list of reasons why it is better developed remotely when all applications work simultaneously in a similar area. Therefore, I want example.com/page1 to refer to my local instance, so I do not send files via FTP every Cmd + S.

From Apache settings, I can map the local URL to the remote one by making it using ProxyPass

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

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

I have two identical web applications working remotely and locally.

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

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

I need to make it work this way:

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

Saving the remote URL in the address bar of the browser.

Is it possible to install it on my end (not with ProxyPass on the remote side)

Perhaps some kind of Chrome extension or proxy application?

+5
source share
2 answers

It is not so simple, and it is completely different from a proxy pass.

When the user enters "example.com" in his browser, the browser decides where to send the request, your nginx configuration has no effect. However, the browser uses DNS to make the decision, and you can prevent it.

If you have control over the DNS users, you can rewrite the example.com domain so that the requests will come to your local server instead. If this is your local machine, you can do this in / etc / hosts. After that, it is as simple as adding example.com to the server_name tag in the nginx configuration.

Another option is to configure the router, but I assume this is not an option for you.

+4
source

If I understand your request correctly, this is what I do all the time in Nginx:

I will / go to my web server and whatever, and "_" go to my Elasticsearch server (for example, / index / type / _search), so my whole domain is actually several systems, combining the domain name and reducing The cost of SSL certificates.

Here is an example Nginx configuration:

 server { listen 10.1.40.2:80; #+ your example location ~ /app { #+ another server proxy_pass http://10.1.40.11:80; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } #+ your example location ~ /homepage { #+ another server proxy_pass http://10.1.40.10:80; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } location ~ /_ { #+ different port proxy_pass http://127.0.0.1:9200; proxy_http_version 1.1; proxy_set_header Connection "Keep-Alive"; proxy_set_header Proxy-Connection "Keep-Alive"; } location / { proxy_pass http://127.0.0.1:80; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } } 
0
source

Source: https://habr.com/ru/post/1242041/


All Articles