Question

How to set up rails app with Nginx/Capistrano

Posted May 22, 2021 46 views
Ruby on RailsNginxDeployment

Hi all, sorry for this stupid question but I don’t know how to figure out this issue.
I can’t run my app after changed SSL to certbot.

My NGINX config:
/etc/nginx/conf.d/airstage.co.conf (it was chenged by certbot)

server {
    server_name airstage.co www.airstage.co;
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/airstage.co/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/airstage.co/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {    
    if ($host = www.airstage.co) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    if ($host = airstage.co) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name airstage.co www.airstage.co;
    return 404; # managed by Certbot
}

And here /etc/nginx/sites-available/default

upstream app {
  server unix:///home/deploy/airstage_web/shared/tmp/sockets/puma.sock fail_timeout=0;
}
server {
        root /home/deploy/airstage_web/current/public;
        try_files $uri/index.html $uri @app;
        location /home/deploy/airstage_web/current/public {
          autoindex on;
          autoindex_exact_size off;
        }
        location @app {
                        proxy_pass http://app;
                proxy_set_header X-Forwarded-Proto https;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_redirect off;
                proxy_buffer_size 128k;
                proxy_buffers 4 256k;
                proxy_busy_buffers_size 256k;
        }
        location ^~ /assets/ {
                gzip_static on;
                expires max;
                add_header Cache-Control public;
        }
        error_page 500 502 503 504 /500.html;
        client_max_body_size 1G;
        keepalive_timeout 10;
}

This all returned me Welcome to nginx! page or if I moved root path nginx/conf.d/airstage.co.conf

[error] 14714#14714: *763 directory index of "/home/deploy/airstage_web/current/public/" is forbidden, client: My_IP, server: airstage.co, request: "GET / HTTP/1.1", host: "www.airstage.co"

My web server is (include version): nginx/1.10.3 (Ubuntu)

The operating system my web server runs on is (include version): Ubuntu 16.04

Domain: GoDaddy.

edited by MattIPv4
Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!