Skip to content

Instantly share code, notes, and snippets.

@rchampourlier
Last active September 10, 2016 11:36
Show Gist options
  • Save rchampourlier/248895d25ef002e2c1b4c1cd7007b391 to your computer and use it in GitHub Desktop.
Save rchampourlier/248895d25ef002e2c1b4c1cd7007b391 to your computer and use it in GitHub Desktop.
Nginx server conf file for Phoenix local development
# This config for Nginx provides you a local domain
# (www.phoenix.dev) for Phoenix webserver development.
#
# ## Prerequisites
# - You must update you /etc/hosts file accordingly.
# - You must create a self-signed certificate if you
# intend on using the HTTPS proxying.
#
# Add this file in the /servers directory accompanying
# your nginx.conf file.
#
# See [this article](https://medium.com/jobteaser-dev-team/the-basic-solution-for-local-domains-d6a0f73bace4#.8el52u5i0)
# for more information.
# HTTP
server {
listen 80;
server_name www.phoenix.dev;
location / {
proxy_pass http://localhost:4000;
}
# Phoenix livereload (using websockets)
location /phoenix/ {
proxy_pass http://localhost:4000/phoenix/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
# HTTPS
server {
listen 443 ssl;
server_name www.phoenix.dev;
ssl_certificate phoenix.crt;
ssl_certificate_key phoenix.key;
location / {
proxy_pass http://localhost:4000;
}
# Phoenix livereload (using websockets)
location /phoenix/ {
proxy_pass http://localhost:4000/phoenix/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment