Curated list of episodes, bundled to help you on your learning path!
Videos of tech, infrastructure, hardware and software which non-instructional by nature.
Articles around software and tutorials.
Show your love and support while looking fancy.
Got a question or want to chat about a topic? Let's talk!
Hi,
Please add nginx with puma configuration for production.
Thanks.
This is the config that I use for nginx/puma. The puma.rb is within the rails application's config folder.
nginx.conf
upstream backend { server unix:///var/run/puma/my_app.sock;}server { listen 80; server_name _ localhost; access_log /var/log/nginx/access.log main; error_log /var/log/nginx/error.log; large_client_header_buffers 8 32k; root /var/app/current/public; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_buffers 8 32k; proxy_buffer_size 64k; proxy_pass http://backend; proxy_redirect off; # enables WS support location /cable { proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Upgrade "websocket"; proxy_set_header Connection "Upgrade"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } location /assets { alias /var/app/current/public/assets; gzip_static on; gzip on; expires max; add_header Cache-Control public; } location /public { alias /var/app/current/public; gzip_static on; gzip on; expires max; add_header Cache-Control public; }}
config/puma.rb
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }threads 2, threads_countport ENV.fetch("PORT") { 3000 }environment ENV.fetch("RAILS_ENV") { "development" }workers ENV.fetch("WEB_CONCURRENCY") { 2 }preload_app!before_fork do ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)endon_worker_boot do ActiveRecord::Base.establish_connection if defined?(ActiveRecord)endplugin :tmp_restart
Thanks, one more thing is don't we need daemonize to run puma in background and environment is pointing to "development" in pumb.rb but it should be "production".
Hi,
Please add nginx with puma configuration for production.
Thanks.
This is the config that I use for nginx/puma. The puma.rb is within the rails application's config folder.
nginx.conf
config/puma.rb
Thanks, one more thing is don't we need daemonize to run puma in background and environment is pointing to "development" in pumb.rb but it should be "production".