google-cloud-platformgoogle-compute-engineubuntu-18.04http-proxysquid

Squid proxy at ubuntu 18.04 impossible to connect


I'm new with Google Cloud so I may explain not precise.\ I have VM with Ubuntu 18.04 at Google Cloud Platform and I have installed Squid 3 proxy server on it. Proxy is already configured a little.

http_port 3128 transparent
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 2
auth_param basic realm My Proxy Server
auth_param basic credentialsttl 24 hours
auth_params basic casesensitive off

#add acl rules
acl users proxy_auth REQUIRED

#http access rules
http_access deny !users
http_access allow users

In Google console I can see server's outer IP address but It does not work through it.

The ifconfig command shows next

ens4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1460
        inet 10.156.0.3  netmask 255.255.255.255  broadcast 0.0.0.0
        inet6 fe80::4001:aff:fe9c:3  prefixlen 64  scopeid 0x20<link>
        ether 42:01:0a:9c:00:03  txqueuelen 1000  (Ethernet)
        RX packets 104399  bytes 83418274 (83.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 93840  bytes 12598292 (12.5 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 16697  bytes 1149429 (1.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16697  bytes 1149429 (1.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

where inet 10.156.0.3 means my inner IP. I suppose I don't understand some simple rule of work with Google Platform or just with proxy configuration.

May you show me where I'm wrong? Thank you.


Solution

  • To solve your issue you need to check with nmap which ports are open on your VM and if 3128 is closed set Network tag for your VM and add firewall rule to allow access to it.

    I've tried to replicate your issue on my test VM:

    1. create VM instance or use existing one
    2. install Squid
    3. check if Squid is running:

      $ sudo systemctl status squid 
       ● squid.service - LSB: Squid HTTP Proxy version 3.x
         Loaded: loaded (/etc/init.d/squid; generated)
         **Active: active (running)** since Wed 2020-02-19 11:47:50 UTC; 26s ago
      
    4. check accessibility to Squid with nmap:

      $ nmap -Pn 35.XXX.155.XXX
      Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-19 12:53 CET
      ...
      Host is up (0.023s latency).
      Not shown: 996 filtered ports
      PORT     STATE  SERVICE
      22/tcp   open   ssh
      3389/tcp closed ms-wbt-server
      8000/tcp closed http-alt
      8081/tcp closed blackice-icecap
      

      Squid is not available

    5. edit VM and set Network tag proxy-server

    6. add firewall rule to enable connections to Squid by using Network tag:

      $ gcloud compute --project=test-prj firewall-rules create proxy-server-rule --direction=INGRESS --priority=999 --network=default --action=ALLOW --rules=tcp:3128 --source-ranges=0.0.0.0/0 --target-tags=proxy-server
      
    7. check accessibility to Squid with nmap again

      $ nmap -Pn 35.XXX.155.XXX
      Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-19 12:53 CET
      ...
      Host is up (0.022s latency).
      Not shown: 995 filtered ports
      PORT     STATE  SERVICE
      22/tcp   open   ssh
      3128/tcp open   squid-http
      3389/tcp closed ms-wbt-server
      8000/tcp closed http-alt
      8081/tcp closed blackice-icecap
      

      now Squid is ready to use.