Skip to content

Instantly share code, notes, and snippets.

@johnnyt
Last active December 24, 2015 12:09
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 johnnyt/6795874 to your computer and use it in GitHub Desktop.
Save johnnyt/6795874 to your computer and use it in GitHub Desktop.
NGINX try_files Apache
# Install NGINX
sudo apt-get install nginx
# Rename github repository to ads_archive
# Create new github repository named ads
REPO_URL="https://github.com/mediaFORGE/ads.git"
ADS_DIR=/mnt/tmp # ??
ADS_ARCHIVE_DIR=/mnt/ads_archive
# Move current ads directory to new frozen directory - it will never be updated again
sudo mv $ADS_DIR $ADS_ARCHIVE_DIR
# Checkout the new ads repo to current location
sudo git clone $REPO_URL $ADS_DIR
server {
listen 4949;
root /mnt/new_ads;
index index.html index.htm;
# Serve static content from the new repo
# Proxy everything else to Apache
location / {
try_files $uri $uri/ @apache;
}
location @apache {
proxy_pass http://127.0.0.1:81;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 4949;
root /mnt/new_ads;
index index.html index.htm;
# Serve static content from the new and archive repos
location / {
try_files $uri $uri/ /archive/$uri /archive/$uri/;
}
# Proxy only php files to Apache
location ~ \.php$ {
proxy_pass http://127.0.0.1:81;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment