Im using Ubuntu 22.04 and everytime I try to use a unix socket in torrc config file the onion service doesn't work
torrc config file:
Log notice file /var/log/tor/log
RunAsDaemon 1
SocksPort 0
DataDirectory /var/lib/tor
HiddenServiceDir /var/lib/tor/gunicorn/
#HiddenServicePort 80 127.0.0.1:80
HiddenServicePort 80 unix:/home/agua/sockets/nginx.sock
nginx site config file:
server {
#listen 80;
listen unix:/home/agua/sockets/nginx.sock;
allow "unix:";
server_name v3onionurlexample.onion
}
the nginx.sock has the following permissions:
namei -nom /home/agua/sockets/nginx.sock
f: /home/agua/sockets/nginx.sock
drwxr-xr-x root root /
drwxr-xr-x root root home
drwxr-xr-x agua agua agua
drwxrwxrwx agua agua sockets
srwxrwxrwx agua www-data nginx.sock
If I use in torrc HiddenServicePort 80 127.0.0.1:80
and in nginx site config file listen 80;
the service works perfectly.
But https://community.torproject.org/onion-services/setup/ reccomends using unix sockets
Any help is well received im new in this
edit:
I have changed the permission to nginx.sock file to the following because im running tor daemon with sudo systemctl start tor
this still doesn't work
namei -nom /home/agua/sockets/nginx.sock
f: /home/agua/sockets/nginx.sock
drwxr-xr-x root root /
drwxr-xr-x root root home
drwxr-xr-x agua agua agua
drwxrwxrwx agua agua sockets
srwxrwxrwx debian-tor www-data nginx.sock
sock file can be read by any user or group so permissions shouldnt be the problem here
tor service status:
tor.service - Anonymizing overlay network for TCP (multi-instance-master)
Loaded: loaded (/lib/systemd/system/tor.service; enabled; vendor preset: enabled)
Active: active (exited) since Fri 2022-06-24 02:13:41 CEST; 26s ago
Process: 39734 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 39734 (code=exited, status=0/SUCCESS)
CPU: 1ms
jun 24 02:13:41 agua-VirtualBox systemd[1]: Stopped Anonymizing overlay network for TCP (multi-instance-master).
jun 24 02:13:41 agua-VirtualBox systemd[1]: Stopping Anonymizing overlay network for TCP (multi-instance-master)...
jun 24 02:13:41 agua-VirtualBox systemd[1]: Starting Anonymizing overlay network for TCP (multi-instance-master)...
jun 24 02:13:41 agua-VirtualBox systemd[1]: Finished Anonymizing overlay network for TCP (multi-instance-master).
edit 2: systemctl status tor@default
tor@default.service - Anonymizing overlay network for TCP
Loaded: loaded (/lib/systemd/system/tor@default.service; enabled-runtime; vendor preset: enabled)
Active: active (running) since Fri 2022-06-24 18:03:26 CEST; 53s ago
Process: 41403 ExecStartPre=/usr/bin/install -Z -m 02755 -o debian-tor -g debian-tor -d /run/tor (code=exited, status=0/SUCCESS)
Process: 41404 ExecStartPre=/usr/bin/tor --defaults-torrc /usr/share/tor/tor-service-defaults-torrc -f /etc/tor/torrc --RunAsDaemon 0 --verify-config (code=exited, status=0/SUCCESS)
Main PID: 41405 (tor)
Tasks: 1 (limit: 1084)
Memory: 49.6M
CPU: 534ms
CGroup: /system.slice/system-tor.slice/tor@default.service
└─41405 /usr/bin/tor --defaults-torrc /usr/share/tor/tor-service-defaults-torrc -f /etc/tor/torrc --RunAsDaemon 0
jun 24 18:03:26 agua-VirtualBox tor[41404]: Jun 24 18:03:26.548 [notice] Tor 0.4.6.10 running on Linux with Libevent 2.1.12-stable, OpenSSL 3.0.2, Zlib 1.2.11, Liblzma 5.2.5, Libzstd 1.4.8 and Glibc 2.3>
jun 24 18:03:26 agua-VirtualBox tor[41404]: Jun 24 18:03:26.548 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://support.torproject.org/faq/staying-anonymous/
jun 24 18:03:26 agua-VirtualBox tor[41404]: Jun 24 18:03:26.549 [notice] Read configuration file "/usr/share/tor/tor-service-defaults-torrc".
jun 24 18:03:26 agua-VirtualBox tor[41404]: Jun 24 18:03:26.550 [notice] Read configuration file "/etc/tor/torrc".
jun 24 18:03:26 agua-VirtualBox tor[41404]: Configuration was valid
jun 24 18:03:26 agua-VirtualBox tor[41405]: Jun 24 18:03:26.572 [notice] Tor 0.4.6.10 running on Linux with Libevent 2.1.12-stable, OpenSSL 3.0.2, Zlib 1.2.11, Liblzma 5.2.5, Libzstd 1.4.8 and Glibc 2.3>
jun 24 18:03:26 agua-VirtualBox tor[41405]: Jun 24 18:03:26.572 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://support.torproject.org/faq/staying-anonymous/
jun 24 18:03:26 agua-VirtualBox tor[41405]: Jun 24 18:03:26.572 [notice] Read configuration file "/usr/share/tor/tor-service-defaults-torrc".
jun 24 18:03:26 agua-VirtualBox tor[41405]: Jun 24 18:03:26.572 [notice] Read configuration file "/etc/tor/torrc".
tor log content
tail /var/log/tor/log
Jun 24 18:03:27.000 [notice] Bootstrapped 5% (conn): Connecting to a relay
Jun 24 18:03:27.000 [notice] Opening Control listener on /run/tor/control
Jun 24 18:03:27.000 [notice] Opened Control listener connection (ready) on /run/tor/control
Jun 24 18:03:27.000 [notice] Bootstrapped 10% (conn_done): Connected to a relay
Jun 24 18:03:28.000 [notice] Bootstrapped 14% (handshake): Handshaking with a relay
Jun 24 18:03:28.000 [notice] Bootstrapped 15% (handshake_done): Handshake with a relay done
Jun 24 18:03:28.000 [notice] Bootstrapped 75% (enough_dirinfo): Loaded enough directory info to build circuits
Jun 24 18:03:28.000 [notice] Bootstrapped 90% (ap_handshake_done): Handshake finished with a relay to build circuits
Jun 24 18:03:28.000 [notice] Bootstrapped 95% (circuit_create): Establishing a Tor circuit
Jun 24 18:03:28.000 [notice] Bootstrapped 100% (done): Done
sudo systemctl start tor
and I have changed permissions in the sock file to the following ``` namei -nom /home/agua/sockets/nginx.sock f: /home/agua/sockets/nginx.sock drwxr-xr-x root root / drwxr-xr-x root root home drwxr-xr-x agua agua agua drwxrwxrwx agua agua sockets srwxrwxrwx debian-tor www-data nginx.sock ```systemctl status tor@default
instead ofsystemctl status tor
. If you could post the tor log contents, that would also be helpful.systemctl status tor@default
and the tor log content