Skip to content

Instantly share code, notes, and snippets.

@alswl
Last active March 28, 2023 06:55
Show Gist options
  • Save alswl/afaae53e85f9ea4b4fe8786af339b99e to your computer and use it in GitHub Desktop.
Save alswl/afaae53e85f9ea4b4fe8786af339b99e to your computer and use it in GitHub Desktop.
Simple proxy on Nginx for Github(and Github user content)
# /etc/nginx/.github.test.com.htpasswd
# htpasswd -nb user password
# PLEASE USE YOUR OWN PASSWORD
user:$apr1$zv2GRYuf$vknySgxsj3DfOav6cdRCv.
# /etc/nginx/conf.d/github.test.com.conf
server {
listen 80;
# mirror for github.com
server_name github.test.com;
access_log off;
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.github.test.com.htpasswd;
location / {
proxy_pass https://github.com/;
proxy_redirect https://objects.githubusercontent.com/ https://ghouc.test.com/;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
# mirror for raw.githubusercontent.com
server_name ghruc.test.com;
access_log off;
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.github.test.com.htpasswd;
location / {
proxy_pass https://raw.githubusercontent.com/;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
# mirror for objects.githubusercontent.com
server_name ghouc.test.com;
access_log off;
auth_basic "Restricted Content";
# no auth for objects, using Github S3 links with time expired
location / {
proxy_pass https://objects.githubusercontent.com/;
proxy_set_header X-Real-IP $remote_addr;
}
}
# vim: set ft=nginx sw=2 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment