I have a site with Nginx hosted on a Droplet, and I’m trying to create a reverse proxy for a subdirectory (/app) to another web application running on the App Platform in a Docker container. Unfortunately, I keep getting a 502 error no matter what I do. It’s possible to set up another site or domain, but not the one I want to run under the App Platform. Is there something I need to enable in the App Platform to allow a reverse proxy?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hello,
In addition to what has already been mentioned, I would recommend following these steps in case that you are having any problems with your nginx server and you are unsure on what the problem is:
If you get an error, you would need to fix that problem and then you could restart nginx:
Syntax OK
when runningnginx -t
then your confiruation is correct, so I would recommend checking your error logs:The log should contain the actual error rather than the generic 502 error. Feel free to share the output of the log here!
Feel free to share the output here and also your Nginx server block reverse proxy config.
And here is also a quick video demo on how to do that as well:
Hope that this helps!
- Bobby
To resolve the 502 error, ensure your Docker container’s app is accessible from the Droplet. Check firewall settings, ensure Nginx is correctly configured with the upstream server details, and verify that the App Platform’s app allows external connections. Also, confirm that Nginx’s proxy settings match the app’s requirements.
Heya,
You can create a reverse proxy from Nginx to the URL generated from the App platform.
A similar idea was shared before in the community before:
https://www.digitalocean.com/community/questions/reverse-proxy-from-droplet-to-app-platform
One other option here would be to just setup a redirect for
domain.com/app)
to go to aapp.domain.com
subdomain. That way you will not have to setup a proxy service to handle all requests, but you can just point the blog subdomain A record to the Droplet and then keep the main domain pointed to the App Platform.Regards