生成nginx配置文件,反向代理google
google的ip地址经常改变,所以要用nslookup去更新ip
#!/bin/env php <?php define("CONF_PATH", '/usr/local/nginx/conf/hosts'); $google_ips = __DIR__ . "/google_ips.txt"; // 保存IP地址文件 $ngx_cnf = CONF_PATH . "/51open.conf"; // NGINX配置文件 exec("nslookup google.com", $out, $ret); $start = false; $ips = []; foreach($out as $line) { // answer: 之后的是服务器对应IP if (false !== strpos($line, "answer:")) { $start = true; } else if (!$start) { continue; } preg_match("/Address: ((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.) {3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))/i", $line, $matches); if (!empty($matches) && isset($matches[1])) { $ips[] = $matches[1]; } } // 保存的IP地址 if (file_exists($google_ips)) { $data = file_get_contents($google_ips); if ($data) { $arr = unserialize($data); if (isset($arr['ips']) && date('Ymd', $arr['__logtime'])==date('Ymd')) { $ips = array_merge($ips, $arr['ips']); $ips = array_unique($ips); } } } $data = ['__logtime' => time(), 'ips' => $ips]; file_put_contents($google_ips, serialize($data)); $str = ''; foreach ($ips as $ip) { $str .= sprintf("\n server %s:80 max_fails=3;", $ip); } if (!$str) { exit; } $ngx_tpl = <<<EOT client_body_buffer_size 512k; proxy_connect_timeout 5; proxy_read_timeout 60; proxy_send_timeout 5; proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 128k; #levels设置目录层次 #keys_zone设置缓存名字和共享内存大小 #inactive在指定时间内没人访问则被删除在这里是1天 #max_size最大缓存空间 proxy_cache_path /data/cache/nginx/51open levels=1:2 keys_zone=51open:20m inactive=1d max_size=2g; upstream google {%s } server { listen 80; server_name g.51open.net google.51open.net; rewrite ^(.*)\$ https://\$host\$1 permanent; } server { listen 443; server_name g.51open.net google.51open.net; ssl on; ssl_certificate /usr/local/nginx/conf/hosts/ssl/g.51open.net.crt; ssl_certificate_key /usr/local/nginx/conf/hosts/ssl/g.51open.net.key; location / { proxy_cache 51open; proxy_cache_key \$host\$uri\$is_args\$args; proxy_cache_valid 200 304 301 302 3d; #哪些状态缓存多长时间 proxy_cache_valid any 1d; #其他的缓存多长时间 proxy_redirect https://www.google.com/ /; proxy_cookie_domain google.com g.51open.net; proxy_pass http://google; proxy_set_header Host "www.google.com"; proxy_set_header Accept-Encoding ""; proxy_set_header User-Agent \$http_user_agent; proxy_set_header Accept-Language "zh-CN"; proxy_set_header Cookie "PREF=ID=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=zh-CN:NW=1: TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2w1IQ-Maw"; # --- 关键字替换 start --- # sub_filter_types text/css text/xml text/javascript; # 过滤类型 sub_filter ssl.gstatic.com g.51open.net; # google会加载ssl.gstatic.com的几个资源和文件 sub_filter www.google.com g.51open.net; sub_filter_once off; # --- 关键字替换 end --- # } ## 反向代理ssl.gstatic.com ## location /gb { proxy_cache 51open; proxy_cache_key \$host\$uri\$is_args\$args; proxy_cache_valid 200 304 301 302 3d; #哪些状态缓存多长时间 proxy_cache_valid any 1d; #其他的缓存多长时间 proxy_pass http://ssl.gstatic.com/gb/; proxy_cookie_domain ssl.gstatic.com g.51open.net; proxy_set_header Accept-Encoding ""; proxy_set_header User-Agent \$http_user_agent; proxy_set_header Accept-Language "zh-CN"; } } EOT; $content = sprintf($ngx_tpl, $str); file_put_contents($ngx_cnf, $content);
以上就是生成nginx配置文件,反向代理google的内容,更多相关内容请关注PHP中文网(www.php.cn)!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

SecList
SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.
