Pod redirects to diaspora.example.org

Just built my pod on centos 7 using nginx and postgresql.
SSL certs are by certbot.
It’s been a struggle getting nginx.conf to work and I tried several examples I found on the web since the one linked in the instructions is “not complete”.
I think I have everything correct but for some reason my pod redirects to diaspora.example.org. I cannot find it anywhere in my nginx.conf or diaspora.yml. Any ideas?

1 Like

Hi!
There is no way the Diaspora configuration would be doing some kind of redirect like that.
First make sure you don’t have some /etc/nginx/conf.d/redirect.conf file that would be doing a redirect.

Nginx is just supposed to do a proxy_pass to your unicorn server. If you properly configured your DNS A record (your.domain. IN A xx.xx.xx.xx) and your server_name in your nginx configuration file is matching that name, there should be no issue.
Also you should check for any other vhost file that would be conflicting with the one you made available for diaspora.

FYI this is the nginx configuration file for the pod diaspora.psyco.fr:

 server {
    listen 80;
    listen 443 ssl http2;
    server_name diaspora.psyco.fr;
    root /path/to/diaspora/public;

    error_page 502 /502.html;
    location /502.html{
    }

    location '/.well-known/acme-challenge' {
        default_type "text/plain";
        root /usr/share/nginx/html;
    }

    location /statistics_json {
        rewrite ^/statistics_json$ /statistics.json;
    }

    # BOSH reverse-proxy for chat server, use only if you need it
    location /http-bind {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto https;

        proxy_redirect off;
        proxy_connect_timeout 5;
        proxy_buffering       off;

        proxy_read_timeout    70;
        keepalive_timeout     70;
        send_timeout          70;

        client_max_body_size 4M;
        client_body_buffer_size 128K;

        proxy_pass http://127.0.0.1:5280;
    }

    # use only if you have CAMO set-up on your server
    location /camo/ {
        proxy_cache CAMO;
        proxy_cache_revalidate on;
        proxy_cache_min_uses 1;
        proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
        proxy_cache_lock on;

        add_header X-Cache-Status $upstream_cache_status;

        access_log /var/log/nginx/access.log cache;

        proxy_redirect off;
        proxy_pass http://127.0.0.1:8081/;
        break;
    }

    # Configure maximum picture size
    # Note that Diaspora has a client side check set at 4M
    client_max_body_size 5M;
    client_body_buffer_size 256K;

    # Proxy if requested file not found
    try_files $uri @diaspora;

    # SSL custom params
    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_trusted_certificate /etc/nginx/ocsp-chain.crt;
    resolver 8.8.4.4 8.8.8.8 valid=300s;
    resolver_timeout 10s;

    location @diaspora {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Host $http_host;
        proxy_redirect off;

        proxy_pass http://127.0.0.1:3000;
    }
} 

Hope it helps.

2 Likes

Thank you for your reply Ruth. This is a fresh install with no previous working web servers so I have nothing in conf.d and default.d. My URL is https pod.mkjpath.us and it still redirects to diaspora.example.org. I suspect it has something to do with the actual diaspora installation since the contents of /public just doesn’t seem to contain any kind of home page.
There is nothing on the installation guide indicating what to do with /public. It seems to compile everything correctly and I have redone it many times. Is it possible I have to drop the postgres DB and create it again?
Discourse won’t allow me to post my nginx.conf that I built from the one you posted because it has more than 2 http destinations.

[root@pod nginx]# tree
.
├── conf.d
├── default.d
├── fastcgi.conf
├── fastcgi.conf.default
├── fastcgi_params
├── fastcgi_params.default
├── koi-utf
├── koi-win
├── mime.types
├── mime.types.default
├── nginx.conf
├── scgi_params
├── scgi_params.default
├── sites-enabled
├── uwsgi_params
├── uwsgi_params.default
└── win-utf

[root@pod nginx]# ls -l /home/diaspora/diaspora/public
total 2812
-rw-rw-r–. 1 diaspora diaspora 746 Aug 7 12:11 404.html
-rw-rw-r–. 1 diaspora diaspora 787 Aug 7 12:11 422.html
-rw-rw-r–. 1 diaspora diaspora 735 Aug 7 12:11 500.html
drwxrwxr-x. 13 diaspora diaspora 16384 Aug 7 12:11 assets
-rw-rw-r–. 1 diaspora diaspora 1150 Aug 7 09:49 favicon.ico
-rw-rw-r–. 1 diaspora diaspora 348 Aug 7 09:49 robots.txt
-rw-rw-r–. 1 diaspora diaspora 2838313 Aug 7 12:35 source.tar.gz

Your pod doesn’t redirect to diaspora.example.org anymore, maybe you had that in your nginx config in the beginning, because you copy/pasted it from the example config, but fixed that now, but your browser still caches the redirect to diaspora.example.org? So you should try clearing your cache.

Also, your public folder looks ok, but it looks like that your nginx config is missing the diaspora upstream and therefore it only shows a 404. Please check again with the example config, if your config is complete: https://gist.github.com/jhass/1355430 (especially lines 107-115 and 118-123, but also line 93)

1 Like

Thank you Benjiman. I had used Ruth’s example and it was missing the upstream section. I added this and still get the 404. I am not sure why discourse will not allow me to paste in my complete nginx.conf unless I remove all the http lines because that is not helpful.

upstream diaspora_server {
server unix:/home/diaspora/diaspora/tmp/diaspora.sock;
}

Also … this is my list of processes which I assume diaspora has all the required processes running as I see no errors in the logs.

diaspora 8208 8207 0 05:30 pts/1 00:00:00 -bash
diaspora 8383 8208 0 05:30 pts/1 00:00:06 eye monitoring v0.10.0 [diaspora] (in /home/diaspora)
diaspora 8565 8383 0 05:30 pts/1 00:00:30 sidekiq 5.1.3 diaspora [0 of 5 busy]
diaspora 8577 1 0 05:30 ? 00:00:13 unicorn master -c config/unicorn.rb -D
diaspora 8593 8577 0 05:31 ? 00:00:00 unicorn worker[0] -c config/unicorn.rb -D
diaspora 8596 8577 0 05:31 ? 00:00:00 unicorn worker[1] -c config/unicorn.rb -D
nginx 9591 9590 0 08:21 ? 00:00:00 nginx: worker process
nginx 9592 9590 0 08:21 ? 00:00:00 nginx: worker process
nginx 9593 9590 0 08:21 ? 00:00:00 nginx: worker process
nginx 9594 9590 0 08:21 ? 00:00:00 nginx: worker process
postgres 1596 1 0 Aug07 ? 00:00:04 /usr/bin/postgres -D /var/lib/pgsql/data -p 5432
postgres 1921 1596 0 Aug07 ? 00:00:00 postgres: logger process
postgres 1926 1596 0 Aug07 ? 00:00:00 postgres: checkpointer process
postgres 1927 1596 0 Aug07 ? 00:00:00 postgres: writer process
postgres 1928 1596 0 Aug07 ? 00:00:00 postgres: wal writer process
postgres 1929 1596 0 Aug07 ? 00:00:04 postgres: autovacuum launcher process
postgres 1930 1596 0 Aug07 ? 00:00:07 postgres: stats collector process
postgres 8590 1596 0 05:31 ? 00:00:00 postgres: diaspora diaspora_production ::1(36682) idle
postgres 8791 1596 0 06:00 ? 00:00:00 postgres: diaspora diaspora_production ::1(36832) idle
redis 1573 1 0 Aug07 ? 00:01:49 /usr/bin/redis-server 127.0.0.1:6379

Have you tried pasting your config in a codeblock instead of pasting it as text (because it worked when ruth posted their config)? Alternatively paste the config to a pastebin of your choice and then link it here.

1 Like

Thanks. I found the problem. I finally thought to look at the nginx error log instead of diaspora log.

(111: Connection refused) while connecting to upstream, client: 174.109.37.60, s… upstream: “http://127.0.0.1:3000/”, …

When I check my diaspora.yml for port 3000;

listen: 'unix:/run/diaspora/diaspora.sock'
#listen: '127.0.0.1:3000'

Diaspora is creating the socket file;
srwxrwxrwx. 1 diaspora diaspora 0 Aug 11 05:31 /run/diaspora/diaspora.sock

So I went back to nginx.conf and changed the proxy_pass from 127.0.0.1:3000;
to proxy_pass http://diaspora_server;

Now my error in nginx error.log is;
[crit] 9894#0: *1 connect() to unix:/home/diaspora/diaspora/tmp/diaspora.sock failed (2: No such file or directory)

SOLUTION:
My problem was that the diaspora.yml file was creating /run/diaspora/diaspora.sock and the example nginx.conf I used was looking for /home/diaspora/diaspora/tmp/diaspora.sock.
A change in nginx.conf to /run/diaspora/diaspora.sock fixed it.
Thanks Ruth and Benjiman.

@pod-mkj glad you resolved your problem. I’ve just visited your pod, and it seems to default to a folder, /podmin/. Is that intentional? I’m not a podmin myself but I think it’s not recommended to have diaspora located inside a folder on your site. A subdomain (which you’ve also used) is the recommended method if you want to have more than one side on that domain.

Let’s see what @supertux88 says.

That’s normal and intentional, diaspora does that until you have configured your first admin user.

1 Like

Ah, OK. Thanks for replying, and apologies for creating a false alert.