Skip to content

Instantly share code, notes, and snippets.

@donrestarone
Created October 14, 2020 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donrestarone/e8b1157dc4a3adffe3450edd55a6f315 to your computer and use it in GitHub Desktop.
Save donrestarone/e8b1157dc4a3adffe3450edd55a6f315 to your computer and use it in GitHub Desktop.
hacky nginx configuration

This hacky configuration is not right. You should always use a unix socket as its more secure and performant. This is setup assuming that there is a server listening on port 3000

RAILS_ENV=production rails db:create
RAILS_ENV=production rails db:migrate
RAILS_ENV=production rails assets:precompile
RAILS_ENV=production rails s
upstream app {
    # a unix socket is defined here but its actually using  proxy_pass http://127.0.0.1:3000; where there is a server listening on port 3000
    server unix:/home/ubuntu/object-detectr/potash/shared/sockets/puma.sock fail_timeout=0;
}

server {
    listen 80;
    server_name localhost;

    root /home/ubuntu/object-detectr/potash/public;

    try_files $uri/index.html $uri @app;

    location @app {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment