Created
March 21, 2020 20:07
-
-
Save ei-grad/2d70c40c7956939f2564b988025ed665 to your computer and use it in GitHub Desktop.
Nginx caching proxy for conda
This file contains hidden or 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
# /etc/nginx/conf.d/conda.conf | |
proxy_cache_path /var/cache/nginx/conda levels=2:2 keys_zone=conda:100m inactive=14d max_size=10g; | |
upstream conda.anaconda.org { | |
server 104.17.92.24:443; | |
server 104.17.93.24:443; | |
} | |
server { | |
listen 80; | |
server_name conda.anaconda.org conda-proxy; | |
location / { | |
proxy_cache conda; | |
proxy_cache_valid 200 365d; | |
proxy_cache_key $request_uri; | |
proxy_pass https://conda.anaconda.org; | |
proxy_http_version 1.1; | |
proxy_set_header Host "conda.anaconda.org"; | |
proxy_set_header Connection ""; | |
proxy_intercept_errors on; | |
error_page 302 = @handle_redirect; | |
} | |
location @handle_redirect { | |
proxy_cache conda; | |
proxy_cache_valid 200 365d; | |
set $saved_uri '$uri'; | |
proxy_cache_key $saved_uri; | |
set $saved_redirect_location '$upstream_http_location'; | |
proxy_pass $saved_redirect_location; | |
proxy_http_version 1.1; | |
proxy_set_header Connection ""; | |
resolver 127.0.0.1; // CHANGE IF THERE IS NO LOCAL DNS CACHE | |
} | |
location ~ .json$ { | |
proxy_pass https://conda.anaconda.org; | |
proxy_cache_valid 200 1d; | |
proxy_cache_key $request_uri; | |
proxy_http_version 1.1; | |
proxy_set_header Host "conda.anaconda.org"; | |
proxy_set_header Connection ""; | |
} | |
} |
This file contains hidden or 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
echo 127.0.0.123 conda-proxy >> /etc/hosts | |
conda config --add channels http://conda-proxy/main | |
conda config --add channels http://conda-proxy/conda-forge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
conda CLI (and conda repository upstream) didn't use cookies at the moment of writing, thanks for notice