1
votes

I have two websites http://localhost:8000/abc and http://localhost:9000/def each deployed on its own apache server. Is there any way I can omit the port and use the apache server to divert to the respective ports by mapping from the url?

For example: http://localhost/abc mapped to port 8000 http://localhost/def mapped to port 9000

1

1 Answers

0
votes

You can indeed, the simplist way to do this would be a proxy. You could install ngenx and configure it with:

_ _ngenix_config_file__

location /abc {
    rewrite /abc/(.*) /$1 break;
    proxy_pass http://localhost:8000;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /def {
    rewrite /def/(.*) /$1 break;
    proxy_pass http://localhost:9000;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

That should do what you want. Of course now we have 3 websites. If the other 2 are literally running off the same Apache instance, it might make more sense to rewrite your apache config to combine them. However regardless of what's going on with them, the above should work.