nginx 正规表达式反向代理 facebook

2016-05-10  本文已影响454人  大福技术

来源:  http://www.oschina.net/code/snippet_993322_45952

server {

listen 80;

server_name you_server_name;

server_tokens off; ## Don't show the nginx version number, a security best practice

rewrite ^ https://$server_name$request_uri? permanent;

}

server {

listen 443;

server_name you_server_name;

ssl on;

ssl_certificate /etc/nginx/ssl/self/xxx.crt;

ssl_certificate_key /etc/nginx/ssl/self/xxx.key;

location / {

proxy_hide_header content-security-policy;

proxy_set_header Accept-Encoding "";

proxy_set_header User-Agent $http_user_agent;

proxy_pass https://www.facebook.com/;

proxy_cookie_domain .facebook.com you_server_name;

subs_filter www.facebook.com you_server_name;

subs_filter 'https://' '/';

subs_filter 'https:\/\/' '\/';

subs_filter 'http://' '/';

subs_filter 'http:\/\/' '\/';

subs_filter '/you_server_name' '';

}

location ~ ^/fbstatic-(.*).akamaihd.net/(.*) {

resolver 8.8.8.8;

proxy_pass https://fbstatic-$1.akamaihd.net/$2;

}

location ~ ^/fbcdn-profile-(.*).akamaihd.net/(.+) {

resolver 8.8.8.8;

proxy_pass https://fbcdn-profile-$1.akamaihd.net/$2?$args;

}

location ~ ^/fbcdn-photos-(.*)-(.*).akamaihd.net/(.*) {

resolver 8.8.8.8;

proxy_pass https://fbcdn-photos-$1-$2.akamaihd.net/$3;

}

location ~ ^/fbcdn-sphotos-(.*)-(.*).akamaihd.net/(.+) {

resolver 8.8.8.8;

proxy_pass https://fbcdn-sphotos-$1-$2.akamaihd.net/$3?$args;

}

location ~ ^/fbexternal-(.*).akamaihd.net/(.+) {

resolver 8.8.8.8;

proxy_pass https://fbexternal-$1.akamaihd.net/$2?$args;

}

location ~ ^/fbcdn-vthumb-(.*).akamaihd.net/(.+) {

resolver 8.8.8.8;

proxy_pass https://fbcdn-vthumb-$1.akamaihd.net/$2?$args;

}

location ~ ^/scontent-(.*).xx.fbcdn.net/(.+) {

resolver 8.8.8.8;

proxy_pass https://scontent-$1.xx.fbcdn.net/$2?$args;

}

location /scontent.xx.fbcdn.net/ {

resolver 8.8.8.8;

proxy_pass https://scontent.xx.fbcdn.net/;

}

location /l.facebook.com/ {

resolver 8.8.8.8;

proxy_pass http://l.facebook.com/;

}

location /error.facebook.com/ {

resolver 8.8.8.8;

proxy_pass https://error.facebook.com/;

}

location /pixel.facebook.com/ {

resolver 8.8.8.8;

proxy_pass https://pixel.facebook.com/;

}

}

上一篇下一篇

猜你喜欢

热点阅读