反向代理怎么实现的?
fatesinger opened this issue · 4 comments
fatesinger commented
最好可以贴下配置文件
surmon-china commented
server {
listen 80;
listen 443 ssl;
server_name api.surmon.me;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 60m;
ssl_session_tickets on;
resolver 114.114.114.114 114.114.115.115 8.8.8.8 valid=300s;
resolver_timeout 10s;
ssl_certificate /usr/local/wwwcert/api.surmon.me/xxxxxx.pem;
ssl_certificate_key /usr/local/wwwcert/api.surmon.me/xxxxxx.key;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security "max-age=31536000";
add_header X-Frame-Options deny;
# add_header Cache-Control no-cache;
# add_header Pragma no-cache;
# add_header Expires 0;
location / {
etag on;
# expires off;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
}
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
access_log off;
error_log /usr/local/wwwlogs/nginx/nodepress.error.log;
}
fatesinger commented
surmon-china commented
# 代理服务
location ~ "^/proxy/(.*)$" {
resolver 114.114.114.114 114.114.115.115 8.8.8.8 valid=300s;
resolver_timeout 10s;
proxy_pass http://$1;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
expires 7d;
}
fatesinger commented
非常感谢!!