nginx端口转发内网使用yum
2024-06-28 16:03:08
供稿:网友
在能上外网的机器192.168.150.14上安装nginx nginx.conf 配置#user nobody;worker_PRocesses 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name mirrors.163.com; #要访问的域名 location / { proxy_pass http://mirrors.163.com; #转发域名 proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } #access_log /home/wwwlogs/access.log access; } server { listen 80; server_name mirror.centos.org; #要访问的域名 location / { proxy_pass http://mirror.centos.org; #转发域名 proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } #access_log /home/wwwlogs/access.log access; } server { listen 80; server_name yum.puppetlabs.com; #要访问的域名 location / { proxy_pass http://yum.puppetlabs.com; #转发域名 proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } #access_log /home/wwwlogs/access.log access; }}客户端 需要yum 到外网的配置:vi /etc/hosts 配置多个域名的映射到跳板机192.168.150.14 mirrors.163.com192.168.150.14 mirror.centos.org192.168.150.14 yum.puppetlabs.comcd /etc/yum.repos.dmkdir oldmkdir *.repo /old下载163的源到本地#见 http://mirrors.163.com/.help/centos.html然后就可以直接使用yum 命令了