By Ryan Paing
Hi all,
I’m trying to create a reverse proxy for my API url and it is not working. The API is working if I use curl localhost:8800. It is on port 8800. My reverse proxy config is as follow:
server {
listen 80;
listen [::]:80;
location /api {
proxy_pass http://localhost:8800;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}
}
I just keep getting 404 error with this. Please help. Thanks.
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!
Hi there @knpaing,
Your Nginx Server Block looks correct, as far as I can see it is configured so that it would work if you visit your_droplet_ip/api. What happens if you run:
curl your_droplet_ip/api
If you are still getting a 404 error, I could suggest checking your Nginx access and error logs:
- tail -100 /var/log/nginx/error.log
- tail -100 /var/log/nginx/access.log
And also making sure that you’ve restarted Nginx so that the reverse proxy rules have been loaded.
Hope that this helps! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.