Last active
August 29, 2015 14:00
-
-
Save stilliard/5f5b530e31d7edadadae to your computer and use it in GitHub Desktop.
simple-nginx-proxy-to-apache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:8080> | |
ServerName PROJECT_NAME.dev | |
ServerAlias www.PROJECT_NAME.dev | |
DocumentRoot PROJECT_DIR | |
<Directory "PROJECT_DIR"> | |
Options Indexes FollowSymLinks | |
AllowOverride All | |
Require all granted | |
</Directory> | |
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
server_name PROJECT_NAME.dev www.PROJECT_NAME.dev; | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $remote_addr; | |
proxy_set_header Host $host; | |
proxy_pass http://www.PROJECT_NAME.dev:8080; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setup | |
PROJECT_NAME=demo | |
PROJECT_DIR=/home/andrew/projects/demo/ | |
# Download the nginx config | |
curl https://gist.githubusercontent.com/stilliard/5f5b530e31d7edadadae/raw/nginx-project -s \ | |
| sed 's/PROJECT_NAME/'$PROJECT_NAME'/g' \ | |
| sudo tee /etc/nginx/sites-available/${PROJECT_NAME}.dev | |
# Download the apache config | |
curl https://gist.githubusercontent.com/stilliard/5f5b530e31d7edadadae/raw/apache-project.dev.conf -s \ | |
| sed 's/PROJECT_NAME/'$PROJECT_NAME'/g' \ | |
| sed 's#PROJECT_DIR#'$PROJECT_DIR'#g' \ | |
| sudo tee /etc/apache2/sites-available/${PROJECT_NAME}.dev.conf | |
# link the files to be enabled | |
sudo ln -s /etc/nginx/sites-available/${PROJECT_NAME}.dev /etc/nginx/sites-enabled/${PROJECT_NAME}.dev | |
sudo ln -s /etc/apache2/sites-available/${PROJECT_NAME}.dev.conf /etc/apache2/sites-enabled/${PROJECT_NAME}.dev.conf | |
# restart services | |
sudo service nginx restart && sudo service apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment