Unsupported Request Method and Protocol

54 views Asked by At

My Nginx server cannot access the internet, but my Squid server can. I now need to configure Nginx to meet my requirements. My goal is to access internet API endpoints through the Nginx server

I want to use Squid as a forward proxy on Nginx. My Nginx is unable to directly access https://qyapi.weixin.qq.com. However, the Squid server can.

my nginx version 1.22.0 nginx.conf

server{

        listen 19999;
        location / {
            rewrite ^(.*)$ "://qyapi.weixin.qq.com$uri";
            rewrite ^(.*)$ "https$uri" break;
            proxy_pass http://ip:3128;
            proxy_set_header Host $host;
        }
}

squid version 5.0.5 squid.conf

acl allowed_ip src  117.62.81.38 


http_access deny allowed_ip
http_access allow all


http_port 3128



coredump_dir /usr/local/squid/var/cache/squid


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

I use the following command: curl http://nginx_ip:19999/cgi-bin/gettoken?corpid=ID&corpsecret=123 and the obtained result is as follows error msg:

ERROR: The requested URL could not be retrieved

body :lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; } :lang(he) { direction: rtl; } -->

ERROR

The requested URL could not be retrieved


The following error was encountered while trying to retrieve the URL: https://qyapi.weixin.qq.com/cgi-bin/gettoken?

Unsupported Request Method and Protocol

Squid does not support all request methods for all access protocols. For example, you can not POST a Gopher request.

Your cache administrator is webmaster.



Generated Fri, 22 Dec 2023 08:23:33 GMT by ecs-2b23 (squid/5.0.5)

ERR_UNSUP_REQ -->

{"errcode":41004,"errmsg":"corpsecret missing, hint: [1703233533317910279823946], from ip: 101.43.111.134, more info at https://open.work.weixin.qq.com/devtool/query?e=41004"}

0

There are 0 answers