When using nginx's reverse proxy function to build a nuget backup storage, you must replace the string with the response content of the official nuget server. For example, you can replace www.nuget.org with the backup storage host name and https: replace with http :. Nginx does not have the built-in function. A third-party module, such as subs_filter, must be used.
When using nginx's reverse proxy function to build an nuget backup storage, you must replace the string with the response content of the official nuget server. For example, you can replace www.nuget.org with the name of the backup storage and https: // Replace with http ://. Nginx does not have the built-in function. A third-party module, such as subs_filter, must be used.
Configuring the module in nginx is not as simple as apache (copying the module File and modifying the configuration file). You need to introduce the module source code to the nginx source code, compile nginx and install it on your own.
The following describes how to compile and install nginx that contains the subs_filter module on centos.
0) If nginx is not installed on centos, install it with yum. Some initial nginx configuration files, such as/etc/rc, will be automatically added during yum installation. d/init. d/nginx,/etc/nginx. conf (these configuration files are not added during self-compilation and installation ).
yum install nginx
1) from the # Source Releases part of the http://wiki.nginx.org/Install to get the nginx Source code, download and unzip.
wget http://nginx.org/download/nginx-1.8.0.tar.gz tar xf nginx-1.8.0.tar.gz
2) git checks out the source code of subs_filter (refer to nginx_substitutions_filter ).
git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
(Note: The save path is/git/ngx_http_substitutions_filter_module)
3) nginx compilation Configuration
./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --add-module=/git/ngx_http_substitutions_filter_module
The last -- add-module is the introduced subs_filter module.
4) Compile and install nginx
make && make install
5) Configure subs_filter in/etc/nginx. config.
server { listen 80; listen [::]:80; server_name [mirror_host_name]; location / { proxy_pass http://www.nuget.org; proxy_cache nuget-cache; proxy_cache_valid 168h; proxy_ignore_headers Set-Cookie Cache-Control; subs_filter www.nuget.org [mirror_host_name]; subs_filter https:// http://; }}
5) restart the nginx Service
systemctl restart nginx
Done!
[References]
CentOS-Installing nginx from source
Websites with Nginx on CentOS 5