.ebextensions/05_nginx_proxy.config
files:
"/etc/nginx/sites-available/000-default.conf":
mode: "000644"
owner: root
group: root
content: |
map $http_upgrade $connection_upgrade {
default "upgrade";
"" "";
}
server {
rewrite_log on;
listen 80;
server_name action.sumofus.org;
location = /a/doritos-video/ {
return 301 https://actions.sumofus.org/a/the-ad-doritos-don-t-want-you-to-see;
}
location /a/Starbucks-deforestation-video {
return 301 https://actions.sumofus.org/a/how-much-do-you-love-starbucks;
}
rewrite ^\/?\w*(\/a\/)([\w-_]+)\/?.*$ https://actions.sumofus.org$1$2? permanent;
location / {
return 301 https://actions.sumofus.org$request_uri;
}
}
server {
listen 80;
server_name community.sumofus.org;
return 301 https://actions.sumofus.org$request_uri;
}
server {
listen 80 default_server;
server_name $APP_DOMAIN;
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;
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;
location = /health {
proxy_pass http://docker;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
}
rewrite ^/petitions/(.*)$ /a/$1 permanent;
location / {
if ($http_x_forwarded_proto != "https")
{
return 301 https://$host$request_uri;
}
proxy_pass http://docker;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
}
}
commands:
00_enable_site:
command: 'rm -f /etc/nginx/sites-enabled/* && ln -s /etc/nginx/sites-available/000-default.conf /etc/nginx/sites-enabled/000-default.conf'