This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 最近有一些需求于是试着用nginx搭建一个全能的反向代理。 | |
| 关键词是“全能”和“反向代理”,所以我们分开一个一个说。 | |
| 反向代理 | |
| server { | |
| listen 0.0.0.0:80; | |
| listen [::]:80; | |
| server_name yyy.zzz.xxx | |
| location / { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8" ?> | |
| <!DOCTYPE html> | |
| <html expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'> | |
| <head> | |
| <meta charset='UTF-8'/> | |
| <meta content='width=device-width' name='viewport'/> | |
| <b:include data='blog' name='all-head-content'/> | |
| <link href='//fonts.googleapis.com/css?family=Merriweather%3A300%2C400%2C700' media='all' rel='stylesheet' type='text/css'/> | |
| <link href='//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' rel='stylesheet'/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| listen 80; | |
| listen [::]:80; | |
| server_name "~^(?<name>.*)\-douban\.ifttl\.com$"; | |
| valid_referers *.ifttl.com ifttl.com; | |
| if ($invalid_referer) { | |
| return 403; | |
| } | |
| location / { | |
| proxy_pass https://$name.doubanio.com; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| location /get/ | |
| { | |
| set $hostx ""; | |
| set $addrs ""; | |
| if ( $uri ~ "^/get/http./+([^/]+)/(.+)$") { | |
| set $hostx $1; | |
| set $addrs $2; | |
| } | |
| resolver 127.0.0.1; | |
| proxy_pass http://$hostx/$addrs; |