Sunday, November 13, 2022

[FIXED] How to proxy all requests to localhost using nginx and plesk?

Issue

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>



Answered By - Pouria
Answer Checked By - Timothy Miller (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.