I have hosted my ROR application on digital ocean using ubuntu droplet, my application is using nginx, passenger. Application web pages are working as expected but there are few api’s that are created in the same application which are giving 403 forbidden when pining the api from react mobile app.
“Completed 403 Forbidden in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms | Allocations: 309)”
I am guessing this is something to do with my nginx configuration can somebody please help.
server {
listen 443 ssl;
server_name net2fit.com;
ssl_certificate /etc/letsencrypt/live/net2fit.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/net2fit.com/privkey.pem;
root /home/deploy/net2fit/public;
passenger_enabled on;
passenger_ruby /home/deploy/.rbenv/versions/2.6.6/bin/ruby;
passenger_app_env production;
access_log /var/log/nginx/app.access.log;
error_log /var/log/nginx/app.error.log;
location /cable {
passenger_app_group_name net2fit_websocket;
passenger_force_max_concurrent_requests_per_process 0;
}
location /api/v1/ {
passenger_enabled on;
rails_env production;
root /home/deploy/net2fit/public;
error_page 500 502 503 504 /50x.html;
}
#Allow uploads up to 100MB in size
client_max_body_size 100m;
location ~ ^/(assets|packs) {
expires max;
gzip_static on;
}
# this rewrites all the requests to the maintenance.html
# page if it exists in the doc root. This is for capistrano's
# disable web task
if (-f $document_root/system/maintenance.html)
{
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
}
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!
On a first glance, everything seems to be okay with Nginx. I do have a couple of questions, does all API calls are being called with – /api/v1/?
Everything else does seem okay so it’s possible the issue is not with Nginx as well but somewhere entirely different.
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.