I have a web app which can be accessed from http://example.com I'm developing locally another web app which I want to access it from the same domain but different path. Let's say I want all traffic from http://example.com/my-local-app/* go to my web app served from localhost:8080. All other requests should go to remote http://example.com. How can I achieve that?

2 Answers 2


You can consider nginx Reverse Proxy.

Example :

location ~ /my-local-app {
    proxy_pass http://localhost:8080/;

In this situation, if any request comes to /my-local-app nginx will forward internally to localhost and return the response as well.

  • The problem is that I want to direct part of traffic to from one domain to localhost and another part to remote host.
    – latata
    Nov 14, 2018 at 8:53
  • You can also do that by proxy_pass. proxy_pass remotehostip:80;
    – Kernelv5
    Nov 16, 2018 at 0:35

You can use virtualhosts for your two applications. One application will be accessible from http://first.example.com and another will be using http://second.example.com. You cannot run one web server on two different ports. Another option is to use nginx as you are using now and install apache on the same machine but configure apache server to run on a different port (8080) whereas nginx is running on port 80. Although not recommended, this would mean you need to manage two different web servers instead of one.

virtualhosts is the way IMO.

  • I need to serve both apps from the exact same domain, only paths define the final destination of request.
    – latata
    Nov 13, 2018 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.