Skip to content

Instantly share code, notes, and snippets.

@KeithP
Last active February 3, 2021 19:50
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save KeithP/f8534c04d20c2b4e4b1d to your computer and use it in GitHub Desktop.
Save KeithP/f8534c04d20c2b4e4b1d to your computer and use it in GitHub Desktop.
# This is to enable WS support. Credits: # https://gist.github.com/Bubelbub/0a942a0d51a3d329897d
# THIS WORKS! for running the example 5.0.0.beta1 chat app on a single instance Elastic beanstalk AWS instance
files:
"/etc/nginx/conf.d/websockets.conf" :
content: |
upstream backend {
server unix:///var/run/puma/my_app.sock;
}
server {
listen 80;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server_name env1.t3tiiauce6.us-west-2.elasticbeanstalk.com
# prevents 502 bad gateway error
large_client_header_buffers 8 32k;
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;
# prevents 502 bad gateway error
proxy_buffers 8 32k;
proxy_buffer_size 64k;
proxy_pass http://backend;
proxy_redirect off;
location /assets {
root /var/app/current/public;
}
# enables WS support
location /cable {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
}
container_commands:
01restart_nginx:
command: "service nginx restart"
@LEEY19
Copy link

LEEY19 commented Aug 12, 2017

@Ravenclaw968 @jasmo2 did you guys manage to solve the abovementioned problem in the end?

@ismailakbudak
Copy link

ismailakbudak commented Nov 30, 2017

is there a solution for eb deploy exception:

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (2: No such file or directory)
2017/11/30 10:06:23 [emerg] 13178#0: open() "/var/log/nginx/error.log" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed.

@imgarylai
Copy link

Did anyone use config.force_ssl = true in your production.rb? I use this nginx config with the setting. However, I keep getting 301 redirection.

@fadec
Copy link

fadec commented Apr 6, 2018

In my experience config.force_ssl = true in Rails lead to a redirect loop for a proxy_pass http://.... I force ssl using nginx redirects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment