/nginx.conf Secret
Created
March 31, 2016 01:06
Star
You must be signed in to star a gist
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
http | |
{ | |
... | |
# nginx may need to resolve domain names at run time | |
resolver 8.8.8.8 8.8.4.4; | |
# Pacman Cache | |
server | |
{ | |
listen 8080; | |
server_name cache.domain.local; | |
root /srv/http/pacman-cache; | |
autoindex on; | |
# Requests for package db and signature files should redirect upstream without caching | |
location ~ \.(db|sig)$ { | |
proxy_pass http://mirrors$request_uri; | |
} | |
# Requests for actual packages should be served directly from cache if available. | |
# If not available, retrieve and save the package from an upstream mirror. | |
location ~ \.tar\.xz$ { | |
try_files $uri @pkg_mirror; | |
} | |
# Retrieve package from upstream mirrors and cache for future requests | |
location @pkg_mirror { | |
proxy_store on; | |
proxy_redirect off; | |
proxy_store_access user:rw group:rw all:r; | |
proxy_next_upstream error timeout http_404; | |
proxy_pass http://mirrors$request_uri; | |
} | |
} | |
# Upstream Arch Linux Mirrors | |
# - Configure as many backend mirrors as you want in the blocks below | |
# - Servers are used in a round-robin fashion by nginx | |
# - Add "backup" if you want to only use the mirror upon failure of the other mirrors | |
# - Separate "server" configurations are required for each upstream mirror so we can set the "Host" header appropriately | |
upstream mirrors { | |
server localhost:8001; | |
server localhost:8002 backup; | |
server localhost:8003 backup; | |
} | |
# Arch Mirror 1 Proxy Configuration | |
server | |
{ | |
listen 8001; | |
server_name localhost; | |
location / { | |
proxy_pass http://mirror.rit.edu$request_uri; | |
proxy_set_header Host mirror.rit.edu; | |
} | |
} | |
# Arch Mirror 2 Proxy Configuration | |
server | |
{ | |
listen 8002; | |
server_name localhost; | |
location / { | |
proxy_pass http://mirrors.acm.wpi.edu$request_uri; | |
proxy_set_header Host mirrors.acm.wpi.edu; | |
} | |
} | |
# Arch Mirror 3 Proxy Configuration | |
server | |
{ | |
listen 8003; | |
server_name localhost; | |
location / { | |
proxy_pass http://lug.mtu.edu$request_uri; | |
proxy_set_header Host lug.mtu.edu; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment