「已注销」 2017-12-12 07:11 采纳率: 66.7%
浏览 3112
已采纳

nginx反向代理如何全站代理?

nginx反向代理到163,但是这种情况下,只是代理了一个页面而已,如果在页面上随便点击一个连接就跳转了,然后就跟我的nginx没啥关系了,这个算是代理吗。。。。

图片说明
图片说明

 upstream uicps  {
#    server 192.168.16.32:59002 weight=1;
     server  www.163.com;
}

## Start 16.32 ##
server {
    listen 9000;
    server_name  localhost;

#    access_log  logs/proxy34.access.log  main;
#    error_log  logs/proxy34.error.log;
    root   html;
    index  index.html index.htm index.php;

    ## send request back to 16.32 ##
    location / {

        #return 404;
        proxy_pass  http://uicps;

        #Proxy Settings
        proxy_redirect     off;
        proxy_set_header   Host     www.163.com;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_max_temp_file_size 0;
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
   }
}
  • 写回答

1条回答 默认 最新

  • COCO_AS 2017-12-12 08:14
    关注

    需要自已编一个nginx, 加上ngx_http_sub_module

    location / {
        sub_filter '<a href="http://xxx.com/'  '<a href="https://$host/';
        sub_filter '<img src="http://xxx.com/' '<img src="https://$host/';
        sub_filter_once on;
    }
    
    

    参考:

    http://nginx.org/en/docs/http/ngx_http_sub_module.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

    报告相同问题?

    悬赏问题

    • ¥15 请教一下simulink中S函数相关问题
    • ¥15 Hadoop中eclipse运行问题
    • ¥15 在二层网络中,掩码存在包含关系即可通信
    • ¥15 端口转发器解析失败不知道电脑设置了啥
    • ¥15 Latex算法流程图行号自定义
    • ¥15 关于#python#的问题:我在自己的电脑上运行起来总是报错,希望能给我一个详细的教程,(开发工具-github)
    • ¥40 基于51单片机实现球赛计分器功能
    • ¥15 cs2游戏画面卡住,应用程序sid与指挥者sid不匹配
    • ¥15 实验七:Pandas要有实验截图和代码
    • ¥15 TypeError: Make sure that the iterable only contains strings.