Sample Header Ad - 728x90

Prevent requests to 127.0.0.1 from being forwarded to http_proxy

3 votes
1 answer
1826 views
I have this on my machine:
$ cat /etc/profile.d/proxy.sh 
export http_proxy=http://192.168.1.30:3128 
export https_proxy=https://192.168.1.30:3128 
That works great, until I need to use an HTTP interface with an application on the localhost.
$ wget localhost
--2023-03-02 06:54:52--  http://localhost/
Connecting to 192.168.1.30:3128... connected.
Proxy request sent, awaiting response... 503 Service Unavailable
2023-03-02 06:54:52 ERROR 503: Service Unavailable.

$ wget 127.0.0.1
--2023-03-02 06:55:20--  http://127.0.0.1/ 
Connecting to 192.168.1.30:3128... connected.
Proxy request sent, awaiting response... 403 Forbidden
2023-03-02 06:55:20 ERROR 403: Forbidden.
Is there a way to prevent localhost and 127.0.0.1 requests from being forwarded to the proxy? --- Details: This machine isn't connected directly to the internet. It has no gateway or default route. But it is on a LAN with a proxy machine (192.168.1.30) that has a proxy server installed (port 3128) and has an internet connection.
$ ip addr
1: lo: ...
    inet 127.0.0.1/8 scope host lo
2: eno1: ...
    altname enp24s0f0
    inet 192.168.1.100/24 brd 192.168.1.255 scope global eno1

$ ip route
192.168.1.0/24 dev eno1 proto kernel scope link src 192.168.1.100

$ cat /etc/hosts
127.0.0.1   localhost

$ cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eno1
iface eno1 inet static
    address 192.168.1.100
    netmask 255.255.255.0
Asked by Stewart (15631 rep)
Mar 2, 2023, 12:34 PM
Last activity: Mar 2, 2023, 01:30 PM