Created
December 5, 2011 18:38
-
-
Save agibralter/1434708 to your computer and use it in GitHub Desktop.
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
upstream haproxy { | |
server 127.0.0.1:85; | |
} | |
server { | |
server_name example.com; | |
# ... other stuff (locations, etc.) | |
location / { | |
proxy_pass http://haproxy; | |
} | |
location ^~ /assets/ { | |
# Originally I had a rewrite... but I'd rather not redirect the client. | |
# rewrite ^ $scheme://<%= @asset_server_name %>$request_uri permanent; | |
proxy_set_header Host assets.example.com; | |
proxy_pass http://asset_server; | |
} | |
location ~* "^/foo.js$" { | |
proxy_set_header Host assets.example.com; | |
proxy_pass http://asset_server; | |
} | |
} | |
upstream asset_server { | |
server xxx.xxx.xxx.xxx:8000; | |
} | |
server { | |
server_name assets.example.com; | |
# Is this location block necessary if there's nothing else in this sever block? | |
location / { | |
proxy_pass http://asset_server; | |
} | |
} |
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 { | |
listen 8000; | |
server_name assets.example.com; | |
root /home/foo/app/public; | |
# Allow all assets to be cached by CloudFront and browsers. | |
add_header Cache-Control public; | |
# Default expires of 1 hour. | |
expires 1h; | |
# Only set far-future expires for assets with hashes. Note: since max_expire | |
# contains curly brackets in the regexp, we must use quotes. | |
location ~* "-[0-9a-f]{32}\.(ico|css|js|gif|jpe?g|png|eot|ttf|otf|woff|svg)(\.gz)?$" { | |
expires max; | |
} | |
# Legacy support for /foo.js: it should be in /assets: /assets/foo.js: | |
location ~* "^/foo.js$" { | |
# Originally I had a rewrite... but I'd rather not redirect the client. | |
# rewrite ^ $scheme://assets.example.com/assets/foo.js permanent; | |
root /home/foo/app/public/assets; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment