D10s
D10s

Reputation: 11

how to change url host link in backend server to another

I want to modify link content with any proxy as a reverse proxy (haproxy, nginx or apache). The backend server has a simple link that redirects to another host ( this host is in an isolated network, only proxy have access).

But when I try to connect, this link redirects to host unattainable for my, the proxy does not know and does not receive any request.

proxy = 10.10.10.1
backend = 30.30.30.1
link_to_another_host = 30.30.30.2
final_user = 10.10.10.3 ( cant connect to net 30.30.30.x )
Is there any way to solve this? 

Simple haproxy example

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend  main 
     bind 10.10.10.1:443 ssl crt /etc/haproxy/haproxy.pem

#    use_backend static          if url_static
    default_backend             app


#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
    balance     roundrobin
    server  app1 30.30.30.1:443 check ssl verify none

link backend server app1

<a href="http://30.30.30.2:8080">link_to_another_host</a>

Upvotes: 0

Views: 759

Answers (1)

D10s
D10s

Reputation: 11

solved with nginx: replace url link with sub_filter important all compression disable

    server {
        listen      80 default_server;
        listen      [::]:80 default_server;
        server_name null;


        location / {
            proxy_pass http://30.30.30.1/;
            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 Accept-Encoding ""; # no compression allowed or next won't work
           sub_filter "http://30.30.30.2:8080" "http://10.10.10.1:80/new_link";
           sub_filter_once off;
 }
     }


Upvotes: 1

Related Questions