로컬 웹 서비스(Apache2 기본 웹페이지)에 연결하는 데 문제가 있습니다. wget
서버를 사용하여 간단한 HTTP:GET 요청을 수행하면 503 Service unavailable
. 그러나 , 나는 을 sudo wget
얻습니다 200 OK
.
$ wget localhost
--2023-03-02 04:58:46-- http://localhost/
Connecting to 10.10.1.30:3128... connected.
Proxy request sent, awaiting response... 503 Service Unavailable
2023-03-02 04:58:46 ERROR 503: Service Unavailable.
$ wget 127.0.0.1
--2023-03-02 04:59:13-- http://127.0.0.1/
Connecting to 10.10.1.30:3128... connected.
Proxy request sent, awaiting response... 403 Forbidden
2023-03-02 04:59:13 ERROR 403: Forbidden.
$ sudo wget localhost
--2023-03-02 04:59:32-- http://localhost/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10701 (10K) [text/html]
Saving to: ‘index.html’
index.html 100%[=================>] 10.45K --.-KB/s in 0s
2023-03-02 04:59:32 (365 MB/s) - ‘index.html’ saved [10701/10701]
이것이 어떻게 가능한지?
몇 가지 세부 사항을 비교하면 다음과 같습니다.
$ wget localhost --debug | $ sudo wget localhost --debug
... | ...
---request begin--- | ---request begin---
GET http://localhost/ HTTP/1.1 | GET / HTTP/1.1
User-Agent: Wget/1.21 | User-Agent: Wget/1.21
Accept: */* | Accept: */*
Accept-Encoding: identity | Accept-Encoding: identity
Host: localhost | Host: localhost
Connection: Keep-Alive | Connection: Keep-Alive
Proxy-Connection: Keep-Alive |
---request end--- | ---request end---
Proxy request sent, awaiting response... | HTTP request sent, awaiting response...
---response begin--- | ---response begin---
HTTP/1.1 503 Service Unavailable | HTTP/1.1 200 OK
Server: squid/3.5.28 | Server: Apache/2.4.54 (Debian)
Mime-Version: 1.0 | Last-Modified: Tue, 09 Aug 2022 17:13:01 GMT
Date: Thu, 02 Mar 2023 10:08:29 GMT | Date: Thu, 02 Mar 2023 10:11:58 GMT
Content-Type: text/html;charset=utf-8 | Content-Type: text/html
Content-Length: 3718 | Content-Length: 10701
X-Squid-Error: ERR_DNS_FAIL 0 | ETag: "29cd-5e5d20b6c3ce8"
Vary: Accept-Language | Vary: Accept-Encoding
Content-Language: en | Accept-Ranges: bytes
X-Cache: MISS from mgmt-11102 | Keep-Alive: timeout=5, max=100
Via: 1.1 mgmt-11102 (squid/3.5.28) |
Connection: keep-alive | Connection: Keep-Alive
---response end--- | ---response end---
...
내 요청이 프록시로 전달되는 이유는 무엇인가요?
프록시는 게이트웨이/방화벽이지만 이 요청이 이 시스템을 전혀 떠나는 것에 놀랐습니다. curl
및 를 사용하여 유사한 동작을 관찰할 수 있습니다 python3.urllib
.
다음은 시스템의 일부 세부정보입니다.
$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 host
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
$ cat /etc/apt/apt.conf.d/99HttpProxy
Acquire::http::Proxy "http://10.10.1.30:3128";
Acquire::http::No-Cache true;
Acquire::http::Pipeline-Depth 0;
$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
6: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 78:ac:44:56:dc:b8 brd ff:ff:ff:ff:ff:ff
altname enp24s0f0
inet 10.10.1.1/24 brd 10.10.1.255 scope global eno1
valid_lft forever preferred_lft forever
$ ip route
10.10.1.0/24 dev eno1 proto kernel scope link src 10.10.1.1
$ cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eno1
iface eno1 inet static
address 10.10.1.1
netmask 255.255.255.0
답변1
약간의 연구 끝에 나는 이것을 시도했습니다.
$ env | grep proxy
http_proxy=http://10.10.1.30:3128
https_proxy=https://10.10.1.30:3128
wget
이것이 , 이(가 curl
) urllib
프록시에 요청을 보내는 원인입니다 .
이렇게 하면 문제가 일시적으로 해결됩니다.
$ unset http_proxy
$ wget localhost
나는 그것이 어디에 설정되어 있는지 알아내기 위해 이것을 했습니다:
$ cd /etc
$ grep -rw http_proxy
profile.d/proxy.sh:export http_proxy=http://10.10.1.30:3128
이제 로컬 서버에 연결해야 하는 도구를 사용할 때마다 unset
변수만 있으면 됩니다. 그런 다음 인터넷에 연결되는 도구를 사용할 때마다 복원합니다.