Skip to content

Instantly share code, notes, and snippets.

@seangwright
Created March 4, 2017 17:49
Show Gist options
  • Save seangwright/306ddc730ccc919429d868671484270c to your computer and use it in GitHub Desktop.
Save seangwright/306ddc730ccc919429d868671484270c to your computer and use it in GitHub Desktop.
nginx domain specific css configuration
// branda.local/styles.css
p {
color: red;
}
// brandb.local/styles.css
p {
color: blue;
}
// otherbrand.local/styles.css
p {
color: blue;
}
// default/styles.css
p {
color: yellow;
}
# Brands
127.0.0.1 brandA.local
127.0.0.1 brandB.local
127.0.0.1 thedefaultwebsite.local
127.0.0.1 otherbrand.local
<html>
<head>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<h1>Success</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rerum odit, minima error quod quas culpa, quos a sapiente fugit aut ad dolor est sit nulla asperiores, porro nihil debitis numquam!
</p>
</body>
</html>
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
error_log logs\error.log warn;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs\access.log main;
server_names_hash_bucket_size 64;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
rewrite_log on;
server_name ~^(?<domain>.+)$;
charset utf-8;
root html/wastebits-app;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.html;
}
}
location /styles.css {
try_files /$domain/styles.css /default/styles.css =404;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment