Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

反向代理怎么实现的? #6

Closed
fatesinger opened this issue Aug 14, 2017 · 4 comments
Closed

反向代理怎么实现的? #6

fatesinger opened this issue Aug 14, 2017 · 4 comments

Comments

@fatesinger
Copy link

最好可以贴下配置文件

@surmon-china
Copy link
Owner

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
Copy link
Author

我的意思是 类似于 https://surmon.me/proxy/www.xxx.com/image.png

@surmon-china
Copy link
Owner

# 代理服务
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
Copy link
Author

非常感谢!!

@surmon-china surmon-china pinned this issue Jul 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants