Search code examples
nginxcentosplesknuxt.js

How to proxy all requests to localhost using nginx and plesk?


I need to deploy a Nuxt.js SSR web application on a centos server. Plesk control panel is already on the server so I need to proxy all requests from example.com to localhost:3000 except plesk control panel which is example.com:8443 and an API URL which is example.com/api/v1 (API is in the WWW folder). The Web server used is nginx.

I tried to use nginx proxy mode, but then I can't get access to API or plesk control panel anymore.

I expect to have 3 vhosts on one IP:

  1. www.example.com for web application
  2. www.example.com:8443 for plesk control panel
  3. www.example.com/api/v1 for API

Solution

  • For those with the same problem. this is how i solved it: go to Plesk control panel/ websites and domain/ Apache and Nginx settings in Additional Apache directives section you can add your apache code:

    <Location />
    	ProxyPass http://localhost:3000/
    	ProxyPassReverse http://localhost:3000/
    </Location>
    
    <Location /API/>
    	ProxyPass !
    </Location>