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

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

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

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站