Skip to content

Instantly share code, notes, and snippets.

@MJ111
Created January 31, 2019 06:22
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 MJ111/5da0b1e9e1a336e7475c694fd61af4ae to your computer and use it in GitHub Desktop.
Save MJ111/5da0b1e9e1a336e7475c694fd61af4ae to your computer and use it in GitHub Desktop.
[aws eb nginx proxy] #nginx
files:
/etc/nginx/conf.d/proxy.conf:
mode: "000644"
owner: root
group: root
content: |
upstream nodejs {
server 127.0.0.1:5000;
keepalive 256;
}
server {
listen 8080;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
access_log /var/log/nginx/access.log main;
location /health {
add_header 'Content-Type' 'application/json';
return 200 '{"code":"1", "message": "ok"}';
}
location /internal/cb {
return 302 http://$arg_state?$request_uri;
}
location /admin/cb {
return 302 http://$arg_state?$request_uri;
}
location /marketing/cb {
return 302 http://$arg_state?$request_uri;
}
location /karamel_admin/cb {
return 302 http://$arg_state?$request_uri;
}
location / {
proxy_pass http://nodejs;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
gzip on;
gzip_comp_level 4;
gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
location /static {
alias /var/app/current/static;
}
}
/opt/elasticbeanstalk/hooks/configdeploy/post/99_kill_default_nginx.sh:
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash -xe
rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
service nginx stop
service nginx start
container_commands:
removeconfig:
command: "rm -f /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment