export HTTP_PROXY="http://proxy.prd.uledns.com:80/"
export HTTPS_PROXY="http://proxy.prd.uledns.com:443/
root@controller:~# cat /etc/hosts
192.168.2.30 controller
192.168.2.31 controller
192.168.2.32 controller
192.168.157.214 proxy.prd.uledns.com
root@controller:~# cat /etc/profile
export http_proxy="http://proxy.prd.uledns.com:80/"
export https_proxy="http://proxy.prd.uledns.com:443/"
export HTTP_PROXY="http://proxy.prd.uledns.com:80/"
export HTTPS_PROXY="http://proxy.prd.uledns.com:443/"
no_proxy=192.168.*.*,*.local,localhost,127.0.0.1
export no_proxy
source /etc/profile # 不生效再执行下,看nginx日志
nginx服务器配置
root@ubuntu:~# cat /etc/nginx/nginx.conf
user www-data;
#user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
#HTTP proxy #这里位http的正向代理配置
server{
resolver 8.8.8.8;
access_log /var/log/nginx/access_proxy-80.log main;
listen 80;
location / {
root html;
index index.html index.htm;
proxy_pass $scheme://$host$request_uri;
proxy_set_header HOST $http_host;
proxy_buffers 256 4k;
proxy_max_temp_file_size 0k;
proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_next_upstream error timeout invalid_header http_502;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
#HTTPS proxy #这里为:https的正向代理配置
server{
resolver 8.8.8.8;
access_log /var/log/nginx/access_proxy-443.log main;
listen 443;
location / {
root html;
index index.html index.htm;
proxy_pass https://$host$request_uri;
proxy_buffers 256 4k;
proxy_max_temp_file_size 0k;
proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_next_upstream error timeout invalid_header http_502;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
nginx配置http,https代理
1、http_proxy变量需要小写
2、hosts文件得配置域名和ip地址
Linux上配置http上网代理 - he伟_li - 博客园
CentOS 7.X下 -- 配置nginx正向代理支持https - 欧-阳 - 博客园