Squid 反向代理 https 到 nginx,在源站上设置 301 跳转不生效 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
pew
V2EX    NGINX

Squid 反向代理 https 到 nginx,在源站上设置 301 跳转不生效

  •  
  •   pew 2017 年 6 月 23 日 5663 次点击
    这是一个创建于 3220 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Squid 设置如下
    https_port 443 cert=/etc/squid/ssl/123.pem key=/etc/squid/ssl/123.key accel defaultsite=www.aaa.com
    ssl_unclean_shutdown on
    cache_peer 1.2.3.4 parent 443 0 no-query no-digest originserver name=web01 login=PASS ssl sslflags=DONT_VERIFY_PEER front-end-https=on
    acl sites_server_1 dstdomain .aaa.com
    cache_peer_access web01 allow sites_server_1
    http_access allow web01

    然后源站( 1.2.3.4 )配置了 ssl,并且设置了 http 301 跳转到 https
    listen 80;
    server_name www.aaa.com aaa.com ;
    add_header Strict-Transport-Security max-age=15768000;
    return 301 https://www.aaa.com$request_uri;

    但是现在结果是输入 www.aaa.com 访问的是 http://www.aaa.com 未进行跳转
    直接 https://www.aaa.com 是可以访问的

    有没有对 squid 比较了解的大阔,给点建议,在此不胜感激。
    7 条回复    2017-06-23 15:38:35 +08:00
    sparkssssssss
        1
    sparkssssssss  
       2017 年 6 月 23 日
    cache_peer 1.2.3.4 parent 443 0 no-query no-digest originserver name=web01 login=PASS ssl
    改成
    cache_peer 1.2.3.4 parent 80 0
    试试?
    pew
        2
    pew  
    OP
       2017 年 6 月 23 日
    @coolloves
    貌似不行,改了直接无法访问了
    The system returned:

    (71) Protocol error (TLS code: SQUID_ERR_SSL_HANDSHAKE)
    Handshake with SSL server failed: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

    此代理和远端主机无法为处理您的请求在相互可接受的安全设置上协商一致。有可能远端计算机不支持安全连接,或者代理对主机的安全凭据不认可。
    sparkssssssss
        3
    sparkssssssss  
       2017 年 6 月 23 日   1
    我觉得有问题,缓存点改了,只是对源站 80 访问获取文件,你直接不能访问了,是什么情况
    看错误,貌似还是 ssl 方式,能贴全配置看看不?
    pew
        4
    pew  
    OP
       2017 年 6 月 23 日
    @coolloves 改成 80 的话就是下面这样
    # Recommended minimum configuration:
    #

    # Example rule allowing access from your local networks.
    # Adapt to list your (internal) IP networks from where browsing
    # should be allowed
    acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
    acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
    acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
    acl localnet src fc00::/7 # RFC 4193 local private network range
    acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines

    acl SSL_ports port 443
    acl Safe_ports port 80 # http
    acl Safe_ports port 21 # ftp
    acl Safe_ports port 443 # https
    acl Safe_ports port 70 # gopher
    acl Safe_ports port 210 # wais
    acl Safe_ports port 1025-65535 # unregistered ports
    acl Safe_ports port 280 # http-mgmt
    acl Safe_ports port 488 # gss-http
    acl Safe_ports port 591 # filemaker
    acl Safe_ports port 777 # multiling http
    acl CONNECT method CONNECT

    #
    # Recommended minimum Access Permission configuration:
    #
    # Deny requests to certain unsafe ports
    http_access deny !Safe_ports

    # Deny CONNECT to other than secure SSL ports
    http_access deny CONNECT !SSL_ports

    # Only allow cachemgr access from localhost
    http_access allow localhost manager
    http_access deny manager

    # We strngly recommend the following be uncommented to protect innocent
    # web applications running on the proxy server who think the only
    # one who can access services on "localhost" is a local user
    #http_access deny to_localhost

    #
    # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
    #

    # Example rule allowing access from your local networks.
    # Adapt localnet in the ACL section to list your (internal) IP networks
    # from where browsing should be allowed
    http_access allow localnet
    http_access allow localhost

    # And finally deny all other access to this proxy
    # http_access allow all

    # Squid normally listens to port 3128
    visible_hostname localhost

    # http_port 3128

    http_port 80 accel vhost vport
    https_port 443 cert=/etc/squid/ssl/123.pem key=/etc/squid/ssl/123.key accel defaultsite=www.aaa.com
    ssl_unclean_shutdown on
    cache_peer 1.2.3.4 parent 80 0 no-query no-digest originserver name=web01 login=PASS ssl sslflags=DONT_VERIFY_PEER front-end-https=on
    acl sites_server_1 dstdomain .aaa.com
    cache_peer_access web01 allow sites_server_1
    http_access allow web01

    # Uncomment and adjust the following to add a disk cache directory.
    cache_dir ufs /var/spool/squid 10000 32 512




    # Leave coredumps in the first cache dir
    coredump_dir /var/spool/squid

    #
    # Add any of your own refresh_pattern entries above these.
    #
    refresh_pattern ^ftp: 1440 20% 10080
    refresh_pattern ^gopher: 1440 0% 1440
    refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
    refresh_pattern . 0 20% 4320
    pew
        5
    pew  
    OP
       2017 年 6 月 23 日
    @coolloves cache_peer 1.2.3.4 parent 80 0 no-query originserver login=PASS name=web01
    这样改,无法打开网页,提示重定向次数过多--
    sparkssssssss
        6
    sparkssssssss  
       2017 年 6 月 23 日
    现在提示重定向过多,可能需要看看 nginx 的问题???
    pew
        7
    pew  
    OP
       2017 年 6 月 23 日
    @coolloves nginx 就加了个 301
    nginx listen 80;
    server_name www.aaa.com aaa.com ;
    add_header Strict-Transport-Security max-age=15768000;
    return 301 https://www.aaa.com$request_uri;
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1066 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 31ms UTC 23:34 PVG 07:34 LAX 16:34 JFK 19:34
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86