Skip to content

Instantly share code, notes, and snippets.

@geekforbrains
Last active November 5, 2020 04:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geekforbrains/01df7c31fd62f84f453b8bc22217f3c6 to your computer and use it in GitHub Desktop.
Save geekforbrains/01df7c31fd62f84f453b8bc22217f3c6 to your computer and use it in GitHub Desktop.
Nginx reverse proxy for Heroku
upstream heroku {
server myapp.herokuapp.com;
}
server {
server_name ~^(www\.)(?<domain>.+)$;
return 301 $scheme://$domain$request_uri;
}
server {
listen 80 default;
listen 443 ssl;
#server_name _;
ssl off;
ssl_certificate /etc/nginx/ssl/myapp.com.crt;
ssl_certificate_key /etc/nginx/ssl/myapp.com.key;
location ~ \.php$ {
return 444;
}
location / {
proxy_pass http://heroku;
proxy_redirect off;
proxy_read_timeout 5m;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto http;
}
}
@mandarvaze
Copy link

@george-i As per the link :

You can provide your own NGINX config by creating a file named nginx.conf.erb in the config directory of your app

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