Configurazione Nginx per forum Discourse su Tor

Hello all,

I would like to configure Discourse to be a Tor hidden service using nginx. Here is the configuration that I am trying in nginx (it doesn’t work, “server not found”):

server {
    listen unix:/var/run/nginx-onion.sock;
    server_name prostadqmwc6no3n.onion;
    location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

In my tor.conf file I have this:

HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 unix:/var/run/nginx-onion.sock

And in /var/lib/tor/hidden_service I have the hostname and private key files. Tor is running.

Discourse is installed and working on the clearweb, and /var/discourse/shared/standalone/nginx.http.sock exists.

If needed I’m happy to pay someone for an hour or so of work to get this running (I doubt it will take more than that, because I’m probably just being stupid).

Did you look at Template for serving through an .onion address with Docker?

Yes but honestly I can’t make head or tail of it and it seems an over-complicated approach for what I need, which is just a working nginx configuration.

Did you find a solution?

Also how’d you get Discourse it self up and running in tocker for a .onion address? (I want a forum available through tor only)

Yes, here is the working configuration. The problem was pretty simple, it was that originally I tried to use a socket to serve the site, but this didn’t work, so I had to use a port.

server {
    listen 801;
    server_name 127.0.0.1;
   location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Grazie per la rapida risposta!

Un’altra domanda: quali sono le specifiche del tuo server (e per quanti utenti?) / hai apportato modifiche per migliorare le prestazioni su Tor?

Grazie in anticipo!

È una VM Digital Ocean da 2 GB con 105 utenti. Non abbiamo apportato modifiche (tranne un plugin per consentirne la pubblicazione sia su Tor che sul clearweb contemporaneamente).

Un’altra domanda: hai riscontrato problemi con le immagini degli utenti (come la carta di sfondo, il banner del profilo, ecc.) che impiegano molto tempo per caricarsi (immagino sia dovuto a Tor)? Una volta memorizzate nella cache, però, vengono visualizzate correttamente.

Non sono esattamente sicuro di come funzionino gli indirizzi utente di Tor. Ma per me tutti gli IP degli utenti connessi vengono mostrati come 127.0.0.1, il che mi aspetto, ma ho impostato l’intestazione x-forwarded-for in nginx.

Non sono sicuro se gli utenti Tor abbiano qualcosa di simile a un IP all’interno della rete Tor stessa e come far sì che questo venga visualizzato.

Potrebbe essere necessario utilizzare set_real_ip_from