By soduno
Trying to make a proxy from domain: api.example.com to api.example.com:1337. The proxy is working sort of. If I use port 3000 (which is my main site) it all works, just not on 1337.
I have initialised the strapi-app with “yarn build”, and using pm2 to continuing run Node. Also making sure that port 1337 is allowed in the firewall.
Can anyone possible guess what the issue might be? I have tried almost everything I can think of :-)
This is my nginx configuration:
server {
index index.html;
server_name api.example.com;
location / {
proxy_pass http://api.example.com:1337;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
My ufw firewall settings:
To Action From
-- ------ ----
1337/tcp ALLOW Anywhere
1337 ALLOW Anywhere
1337/tcp (v6) ALLOW Anywhere (v6)
1337 (v6) ALLOW Anywhere (v6)
Strapi-app structure:
someuser@someuser-website:~/api$ ls
README.md api build config extensions favicon.ico node_modules package.json public yarn.lock
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 @soduno,
The Nginx configuration actually looks correct. What is the exact error that you get when you visit your API?
Also what I could suggest is making sure that Strapi is listening on the correct port, to do that run the following command:
- sudo netstat -plant
Feel free to share the output here.
On another note, what I could also suggest is checking your Nginx error log with the following command:
- tail -100 /var/log/nginx/error.log
Regards, Bobby
Your Nginx configuration and UFW firewall settings look generally correct for proxying requests to a service running on port 1337. If you’re having trouble accessing your Strapi application through the Nginx proxy, there are several possible issues to consider:
http://api.example.com:1337 directly (if this port is publicly accessible) or by accessing it from the server itself using curl http://localhost:1337.proxy_pass, try using localhost or the server’s internal IP address instead of the domain name:location / {
proxy_pass http://localhost:1337;
# Other directives...
}
Ensure that Nginx is properly reloaded after making configuration changes:
sudo nginx -t
sudo systemctl reload nginx
ufw settings, it seems fine, but it’s good to double-check:sudo ufw status
api.example.com resolves to the correct IP address where your Nginx server is hosted. You can check this with ping or dig commands.localhost or 127.0.0.1 if you’re accessing it from an external server.sudo tail -f /var/log/nginx/error.log
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.