nginx代理其他网站

问题来源:工作当中遇见了尴尬的事,联通商城的选号界面选不出来号码,经过排查原因,是由于我们的电信宽带不能访问联通的数据导致的。那么问题来了,怎样通过代理服务器访问联通的网络?

解决方案:利用nginx代理其他网站,并修改主机的hosts

  nginx配置如下:

  location /{
        rewrite  ^.+apis/?(.*)$ /$1 break;
        include  uwsgi_params;
        proxy_pass  http://admin.mall.10010.com;
    }


   location /admin {
        rewrite  ^.+apis/?(.*)$ /$1 break;
        include  uwsgi_params;
         proxy_pass  http://num.10010.com;
       }

 

  重启nginx

  修改hosts:

@ECHO OFF&PUSHD %~DP0 &TITLE 添加映射

Rd "%WinDir%\system32\test_permissions" >NUL 2>NUL
Md "%WinDir%\System32\test_permissions" 2>NUL||(Echo 请使用右键管理员身份运行!按任意键退出。&&pause >nul&&Exit)
Rd "%WinDir%\System32\test_permissions" 2>NUL
 
echo 当前是管理员运行了
::设置待搜索的文件
set File=C:\Windows\System32\drivers\etc\hosts

::设置要搜索的字符串
set Str=60.205.222.146 admin.mall.10010.com

findstr /i /c:"%Str%" "%File%" >nul 2>nul && echo 已添加过,无需重复添加,按任意键退出 &&Pause >nul&&Exit || echo 正在为您添加
echo. >> C:\Windows\System32\drivers\etc\hosts
echo 60.205.222.146 admin.mall.10010.com >> C:\Windows\System32\drivers\etc\hosts
ipconfig /flushdns
echo "刷新DNS完成"
echo 添加成功,按任意键退出

pause >NUL && EXIT

 

把上面的脚本用记事本写进去改后缀为,bat即可 在主机上执行

问题解决!

 

posted @ 2019-06-12 14:25  左手程序,右手诗  阅读(5045)  评论(0编辑  收藏  举报