Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
VVV Nginx Configuration
# VVV Nginx Configuration
# oxocode
# - Uses proper domain.com extension for verifying
# third party APIs are loading / ads are being served.
# - Allows access to localhost via mobile
# - Uses xip.io for testing RWD via mobile
#
# Assumptions: These rules assume that your
# development site was created in 'local.domain.com'
# within your vagrant public root
#
# Installation: Replace "domain" with the sitename
server {
# Determines the port number that nginx will listen to for this
# server configuration. 80 is the default http port.
listen 80;
# Listen for HTTPS requests as well
listen 443 ssl;
# Tells nginx what domain name should trigger this configuration. If
# you would like multiple domains or subdomains, they can be space
# delimited here. See http://nginx.org/en/docs/http/server_names.html
server_name local.domain.com *.local.domain.com ~^local.domain.com\.\d+\.\d+\.\d+\.\d+\.xip\.io$;
# Tells nginx which directory the files for this domain are located
root /srv/www/local.domain.com/htdocs;
# Includes a basic WordPress configuration to help with the common
# rules needed by a web server to deal with WordPress properly.
include /etc/nginx/nginx-wp-common.conf;
# Directives to send expires headers and turn off 404 error logging.
# Requests are limited to media files
location ~* .(png|jpg|jpeg|gif|ico|swf|mp4|mov|mp3)$ {
expires off;
fastcgi_read_timeout 1000;
log_not_found off;
try_files $uri $uri/ @production;
}
location @production {
resolver 8.8.8.8;
proxy_pass http://domain.com/$uri;
proxy_intercept_errors on;
recursive_error_pages on;
error_page 404 = @staging;
}
location @staging{
resolver 8.8.8.8;
proxy_pass http://staging.domain.com/$uri;
proxy_intercept_errors on;
recursive_error_pages on;
error_page 404 = @develop;
}
location @develop{
resolver 8.8.8.8;
proxy_pass http://develop.domain.com/$uri;
proxy_intercept_errors on;
recursive_error_pages on;
#error_page 404 = // nothing to see here /
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.