Nginx - seafile - https Problem

server

#1

Dear community,

I have been trying to setup my raspberry pi with radicale & seafile (newest Vers: 6.3.2) using https. Radicale is up & running however seafile is only reachable via http but not via https. The Browser simply times out after roughly a minute. The nginx server is running fine and there are no error messages, so i have no idea what I am doing wrong. I have followed this tutorial (http://blog.lewumpy.de/2018/01/private-cloud-seafile-radicale-2/) & the seafile manual (https://manual.seafile.com/deploy/deploy_with_nginx.html). I would like to hear your input, since I am stuck.

ccnet.conf

[General]
USER_NAME = bla
ID = 772fca8d258aa0f418beae554b9936255aacd354
NAME = bla
SERVICE_URL = https://bla.no-ip.de

[Client]
PORT = 13419

seahub_settings.py

# -*- coding: utf-8 -*-
SECRET_KEY = "XXXXXXXXXXXX"
FILE_SERVER_ROOT = 'https://bla.no-ip.de/seafhttp'

seafile.conf

[fileserver]
port=8082
host=127.0.0.1

nginx -> seahub config

server {
    listen       80;
    server_name  bla.no-ip.de;
    rewrite ^ https://$http_host$request_uri? permanent;    # force redirect http to https

    # Enables or disables emitting nginx version on error pages and in the "Server" response header field.
    server_tokens off;
}

server {
    listen 443;
    ssl on;
    ssl_certificate /etc/letsencrypt/live/bla.no-ip.de/fullchain.pem;        # path to your cacert.pem
    ssl_certificate_key /etc/letsencrypt/live/bla.no-ip.de/privkey.pem;    # path to your privkey.pem
    server_name bla.no-ip.de;
    ssl_session_timeout 5m;
    ssl_session_cache shared:SSL:5m;

    # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
    ssl_dhparam /etc/nginx/dhparam.pem;

    # secure settings (A+ at SSL Labs ssltest at time of writing)
    # see https://wiki.mozilla.org/Security/Server_Side_TLS#Nginx
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-SEED-SHA:DHE-RSA-CAMELLIA128-SHA:HIGH:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS';
    ssl_prefer_server_ciphers on;

    proxy_set_header X-Forwarded-For $remote_addr;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
    server_tokens off;

    location / {
        proxy_pass         http://127.0.0.1:8000;
        proxy_set_header   Host $host:$server_port;
#       proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;
        proxy_set_header   X-Forwarded-Proto https;

        access_log      /var/log/nginx/seahub.access.log;
        error_log       /var/log/nginx/seahub.error.log;

        proxy_read_timeout  1200s;

        client_max_body_size 0;
    }

    location /seafhttp {
 	rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass http://127.0.0.1:8082;
        client_max_body_size 0;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_connect_timeout  36000s;
        proxy_read_timeout  36000s;
        proxy_send_timeout  36000s;
        send_timeout  36000s;
    }

    location /media {
        root /home/user/seafile/seafile-server-latest/seahub;
    }


}

Other people had problems with the proxy_set_header Host $host:$server_port; . However i tried with proxy_set_header Host $host; also and nothing changed.
Since I am using the same ssl keys for radicale & that is working, the key are there & active.
I opened Ports 443, 8000 and 8082 for seafile.


#2

There are several issues in your config, like the one above. You should make a diff against the config in the seafile manual and then you can fix it. Additional, you don’t need to open 8000 and 8082 if everything is behind nginx.


#3

Hi,

thank you for your input! I have gone through all my files and they are all identical to what is used on the seafile homepage tutorial (except names and paths). The two lines you mentioned are the only ones where I tried user suggestions I found on various forums (thats why one of them is commented out with #, so only one is used.) I also closed the ports, like you recommended.
I then tried doing everything from scratch again, and it still only works on http. However if I run
nginx -t
i get the following:

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2018/10/07 08:33:16 [warn] 2398#2398: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2018/10/07 08:33:16 [emerg] 2398#2398: BIO_new_file("/etc/letsencrypt/live/bla.no-ip.de/fullchain.pem") failed (SSL: error:0200100D:system library:fopen:Permission denied:fopen('/etc/letsencrypt/live/bla.no-ip.de/fullchain.pem','r') error:2006D002:BIO routines:BIO_new_file:system lib)
nginx: configuration file /etc/nginx/nginx.conf test failed

So the server actually starts and is active but cant get the certificates because of permission issues. My setup is the following: There is a root user and a user “seafile”. The user seafile holds the programm and the programmspecific config mentioned in the last post. nginx is running from the root user. I startet nginx as a root service as far is i understand and yet it still has no permissions.

sudo nano /etc/systemd/system/seafile.service:

[Unit]
Description=Seafile
After=network.target postgresql.service
 
[Service]
Type=oneshot
ExecStart=/home/seafile/seafile-server-latest/seafile.sh start
ExecStop=/home/seafile/seafile-server-latest/seafile.sh stop
RemainAfterExit=yes
User=seafile
Group=seafile
 
[Install]
WantedBy=multi-user.target

sudo nano /etc/systemd/system/seahub.service:

[Unit]
Description=Seafile hub
After=network.target seafile.service
 
[Service]
Environment="LC_ALL=C"
ExecStart=/home/seafile/seafile-server-latest/seahub.sh start
ExecStop=/home/seafile/seafile-server-latest/seahub.sh stop
User=seafile
Group=seafile
Type=oneshot
RemainAfterExit=yes
 
[Install]
WantedBy=multi-user.target

#4

It does not look like the master process of nginx is running as root.
Could you post the output of:
ps aux | grep nginx

How did you install nginx?


#5

Hi, heres the result:

   root       843  0.0  0.1  52172  1288 ?        Ss   00:02   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
    wir+   844  0.0  0.5  52312  5364 ?        S    00:02   0:00 nginx: worker process
    wir+   845  0.0  0.2  52172  2608 ?        S    00:02   0:01 nginx: worker process
    wir+   846  0.0  0.2  52172  2608 ?        S    00:02   0:01 nginx: worker process
    wir+   847  0.0  0.2  52172  2608 ?        S    00:02   0:01 nginx: worker process
    wir+  2563  0.0  0.0   5996   572 pts/0    S+   09:38   0:00 grep --color=auto nginx

I had debian stretch lite, made a temporary user, added “wir” user gave him all permissions and deletet the pi and temp user.

sudo visudo:
wir ALL=(ALL) NOPASSWD: ALL

under that user i installed nginx via install apt-get install nginx.

Edit:
Ok so just to make sure, i changed the user in /etc/nginx/nginx.conf to root. So now when I run your command it looks like this:

root       928  0.0  0.1  52588  1312 ?        Ss   12:01   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
root       929  0.0  0.2  52588  2528 ?        S    12:01   0:00 nginx: worker process
root       930  0.0  0.2  52588  2528 ?        S    12:01   0:00 nginx: worker process
root       931  0.0  0.2  52588  2528 ?        S    12:01   0:00 nginx: worker process
root       932  0.0  0.2  52588  2528 ?        S    12:01   0:00 nginx: worker process
wir+   966  0.0  0.0   5996   552 pts/0    S+   12:03   0:00 grep --color=auto nginx

running nginx -t however I still get the same errors:

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2018/10/07 12:17:05 [warn] 1006#1006: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2018/10/07 12:17:05 [emerg] 1006#1006: BIO_new_file("/etc/letsencrypt/live/bla.no-ip.de/fullchain.pem") failed (SSL: error:0200100D:system library:fopen:Permission denied:fopen('/etc/letsencrypt/live/bla.no-ip.de/fullchain.pem','r') error:2006D002:BIO routines:BIO_new_file:system lib)

#6

The user www-data have to acces nginx’s log files. You have to change the permissions for him.


#7

Ok so I did

sudo chmod -R 777 /var/log/nginx/

and got rid of the log error. So I tried just for the sake of trying to change the permissions for the /etc/live folder to

sudo chmod -R 777 /etc/letsencrypt/live

still got the two remaining warnings postet above…As this is my first project on Linux I’m completly lost.

Edit: using

sudo nginx -t

the errors are gone. But why is this different from giving all groups and users permission?


#8

In ccnet.conf the service_url has to be given without portnumber when configuring seafile with nginx. You need to restart seafile+seahub after changing this.

You say that you can access Seafile via http. Under what link exactly?
Could you post the output of curl -I https:/bla.no-ip.de/?

Can you verify that nginx is actually loading the seahub configuration with sudo nginx -T? Have a look for the seahub configuration in the output


#9

Ok, so since this morning I fiddled around so much, that now even http isn’t working any more. I arrive at the nginx starting page but never to seafile. I want to have seafile appear when just typing in the address. And I wanted radicale running on Port 9175, wich it does fine up until now.
I changed the service URL as you suggested and rebootet.

sudo nginx -T loads all files it is supposed to:

nginx: [warn] conflicting server name "bla.no-ip.de" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "bla.no-ip.de" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "bla.no-ip.de" on [::]:80, ignored
nginx: [warn] conflicting server name "bla.no-ip.de" on 0.0.0.0:443, ignored
nginx: [warn] conflicting server name "bla.no-ip.de" on 0.0.0.0:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:
user root;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 128;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

# configuration file /etc/nginx/modules-enabled/50-mod-http-auth-pam.conf:
load_module modules/ngx_http_auth_pam_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-dav-ext.conf:
load_module modules/ngx_http_dav_ext_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-echo.conf:
load_module modules/ngx_http_echo_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-geoip.conf:
load_module modules/ngx_http_geoip_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-image-filter.conf:
load_module modules/ngx_http_image_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-subs-filter.conf:
load_module modules/ngx_http_subs_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-upstream-fair.conf:
load_module modules/ngx_http_upstream_fair_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-xslt-filter.conf:
load_module modules/ngx_http_xslt_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-mail.conf:
load_module modules/ngx_mail_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-stream.conf:
load_module modules/ngx_stream_module.so;

# configuration file /etc/nginx/mime.types:

types {
    text/html                             html htm shtml;
    text/css                              css;
    text/xml                              xml;
    image/gif                             gif;
    image/jpeg                            jpeg jpg;
    application/javascript                js;
    application/atom+xml                  atom;
    application/rss+xml                   rss;

    text/mathml                           mml;
    text/plain                            txt;
    text/vnd.sun.j2me.app-descriptor      jad;
    text/vnd.wap.wml                      wml;
    text/x-component                      htc;

    image/png                             png;
    image/tiff                            tif tiff;
    image/vnd.wap.wbmp                    wbmp;
    image/x-icon                          ico;
    image/x-jng                           jng;
    image/x-ms-bmp                        bmp;
    image/svg+xml                         svg svgz;
    image/webp                            webp;

    application/font-woff                 woff;
    application/java-archive              jar war ear;
    application/json                      json;
    application/mac-binhex40              hqx;
    application/msword                    doc;
    application/pdf                       pdf;
    application/postscript                ps eps ai;
    application/rtf                       rtf;
    application/vnd.apple.mpegurl         m3u8;
    application/vnd.ms-excel              xls;
    application/vnd.ms-fontobject         eot;
    application/vnd.ms-powerpoint         ppt;
    application/vnd.wap.wmlc              wmlc;
    application/vnd.google-earth.kml+xml  kml;
    application/vnd.google-earth.kmz      kmz;
    application/x-7z-compressed           7z;
    application/x-cocoa                   cco;
    application/x-java-archive-diff       jardiff;
    application/x-java-jnlp-file          jnlp;
    application/x-makeself                run;
    application/x-perl                    pl pm;
    application/x-pilot                   prc pdb;
    application/x-rar-compressed          rar;
    application/x-redhat-package-manager  rpm;
    application/x-sea                     sea;
    application/x-shockwave-flash         swf;
    application/x-stuffit                 sit;
    application/x-tcl                     tcl tk;
    application/x-x509-ca-cert            der pem crt;
    application/x-xpinstall               xpi;
    application/xhtml+xml                 xhtml;
    application/xspf+xml                  xspf;
    application/zip                       zip;

    application/octet-stream              bin exe dll;
    application/octet-stream              deb;
    application/octet-stream              dmg;
    application/octet-stream              iso img;
    application/octet-stream              msi msp msm;

    application/vnd.openxmlformats-officedocument.wordprocessingml.document    docx;
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet          xlsx;
    application/vnd.openxmlformats-officedocument.presentationml.presentation  pptx;

    audio/midi                            mid midi kar;
    audio/mpeg                            mp3;
    audio/ogg                             ogg;
    audio/x-m4a                           m4a;
    audio/x-realaudio                     ra;

    video/3gpp                            3gpp 3gp;
    video/mp2t                            ts;
    video/mp4                             mp4;
    video/mpeg                            mpeg mpg;
    video/quicktime                       mov;
    video/webm                            webm;
    video/x-flv                           flv;
    video/x-m4v                           m4v;
    video/x-mng                           mng;
    video/x-ms-asf                        asx asf;
    video/x-ms-wmv                        wmv;
    video/x-msvideo                       avi;
}

# configuration file /etc/nginx/sites-enabled/default:
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name bla.no-ip.de;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # proxy_pass http://localhost:8080;
                # proxy_http_version 1.1;
                # proxy_set_header Upgrade $http_upgrade;
                # proxy_set_header Connection 'upgrade';
                # proxy_set_header Host $host;
                # proxy_cache_bypass $http_upgrade;
        }

        listen 443 ssl default_server;
        server_name bla.no-ip.de;
        ssl_certificate /etc/letsencrypt/live/bla.no-ip.de/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/bla.no-ip.de/privkey.pem;


        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php7.0-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php7.0-fpm:
        #       fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#       listen 80;
#       listen [::]:80;
#
#       server_name example.com;
#
#       root /var/www/example.com;
#       index index.html;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
#}

# configuration file /etc/nginx/sites-enabled/radicale:
server {
        listen 80;
        listen [::]:80;

        server_name bla.no-ip.de:9175 www.bla.no-ip.de:9175;


        location /radicale/ { #Der / am Ende ist wichtig!
                proxy_pass        http://localhost:9175/; #Der / am Ende ist wichtig!
                include proxy_params;
                proxy_set_header  X-Script-Name /radicale;
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass_header Authorization;
                proxy_ssl_certificate         /etc/letsencrypt/live/bla.no-ip.de/fullchain.pem;
                proxy_ssl_certificate_key     /etc/letsencrypt/live/bla.no-ip.de/privkey.pem;
        }
}

# configuration file /etc/nginx/proxy_params:
proxy_set_header Host $http_host;
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 $scheme;

# configuration file /etc/nginx/sites-enabled/seahub:
server {
        listen       80;
        server_name  bla.no-ip.de;
        rewrite ^ https://$http_host$request_uri? permanent;    # force redirect http to https
        server_tokens off;
    }

server {
        listen 443;
        ssl on;
        ssl_certificate /etc/letsencrypt/live/bla.no-ip.de/fullchain.pem;        # path to your cacert.pem
        ssl_certificate_key /etc/letsencrypt/live/bla.no-ip.de/privkey.pem;    # path to your privkey.pem
        server_name bla.no-ip.de www.bla.no-ip.de;
        ssl_session_timeout 5m;
        ssl_session_cache shared:SSL:5m;

        # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
        ssl_dhparam /etc/nginx/dhparam.pem;

        # secure settings (A+ at SSL Labs ssltest at time of writing)
        # see https://wiki.mozilla.org/Security/Server_Side_TLS#Nginx
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-SEED-SHA:DHE-RSA-CAMELLIA128-SHA:HIGH:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS';
        ssl_prefer_server_ciphers on;

        proxy_set_header X-Forwarded-For $remote_addr;

        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        server_tokens off;

        location / {
            proxy_pass         http://127.0.0.1:8000;
#           proxy_set_header   Host $host:$server_port;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;
            proxy_set_header   X-Forwarded-Proto https;

            access_log      /var/log/nginx/seahub.access.log;
            error_log       /var/log/nginx/seahub.error.log;

            proxy_read_timeout  1200s;

            client_max_body_size 0;
        }

        location /seafhttp {
            rewrite ^/seafhttp(.*)$ $1 break;
            proxy_pass http://127.0.0.1:8082;
            client_max_body_size 0;
            proxy_connect_timeout  36000s;
            proxy_read_timeout  36000s;
            proxy_send_timeout  36000s;
            send_timeout  36000s;
        }

        location /media {
            root /home/user/seafile/seafile-server-latest/seahub;
        }

}

#10

Save this as file /etc/nginx/sites-available/bla.no-ip.de

server {
        listen 80;
        server_name  bla.no-ip.de;
        return 301 https://$http_host$request_uri;    # force redirect http to https
        server_tokens off;
    }

server {
        listen 443 ssl http2;
        server_name bla.no-ip.de;

        ssl_certificate /etc/letsencrypt/live/bla.no-ip.de/fullchain.pem;        # path to your cacert.pem
        ssl_certificate_key /etc/letsencrypt/live/bla.no-ip.de/privkey.pem;    # path to your privkey.pem
        ssl_session_timeout 5m;
        ssl_session_cache shared:SSL:5m;

        # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
        ssl_dhparam /etc/nginx/dhparam.pem;

        # secure settings (A+ at SSL Labs ssltest at time of writing)
        # see https://wiki.mozilla.org/Security/Server_Side_TLS#Nginx
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-SEED-SHA:DHE-RSA-CAMELLIA128-SHA:HIGH:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS';
        ssl_prefer_server_ciphers on;

        proxy_set_header X-Forwarded-For $remote_addr;

        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        server_tokens off;

        location ^~ /radicale/ { #Der / am Ende ist wichtig!
                proxy_pass http://localhost:9175/; #Der / am Ende ist wichtig!
                include proxy_params;
                proxy_set_header  X-Script-Name /radicale;
                proxy_pass_header Authorization;
                proxy_ssl_certificate /etc/letsencrypt/live/bla.no-ip.de/fullchain.pem;
                proxy_ssl_certificate_key /etc/letsencrypt/live/bla.no-ip.de/privkey.pem;
        }

        location / {
            proxy_pass         http://127.0.0.1:8000;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;
            proxy_set_header   X-Forwarded-Proto https;

            access_log      /var/log/nginx/seahub.access.log;
            error_log       /var/log/nginx/seahub.error.log;

            proxy_read_timeout  1200s;

            client_max_body_size 0;
        }

        location /seafhttp {
            rewrite ^/seafhttp(.*)$ $1 break;
            proxy_pass http://127.0.0.1:8082;
            client_max_body_size 0;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_connect_timeout  36000s;
            proxy_read_timeout  36000s;
            proxy_send_timeout  36000s;
            send_timeout  36000s;
        }

        location /media {
            root /home/user/seafile/seafile-server-latest/seahub;
        }
}

then issue the following commands:

sudo rm /etc/nginx/sites-enabled/*
sudo ln -s /etc/nginx/sites-available/bla.no-ip.de /etc/nginx/sites-enabled/bla.no-ip.de`

Check for errors of the configuration with:
sudo nginx -t
If nginx reports errors post them here.
If not, do: sudo systemctl restart nginx

Then try to access Seafile at https://bla.no-ip.de/
and radicale at https://bla.no-ip.de/radicale/

Keeping my fingers crossed…


#11

ok, I did as you said, and removed the existing files out of the sites-available directory.
all services start up and are running.
radicale is only reachable via https://bla.no-ip.de:9175, wich is fine. Using https://bla.no-ip.de/radicale/ gives “Bad Gateway” message in Browser
seafile is accessable via https://bla.no-ip.de, however only in its html text form. So no CSS styles are loaded, loginwindow is missing etc… I only see a blank page listing languages I could switch to.
The same is with https://bla.no-ip.de/seahub.


#12

What is the path to your Seafile directory? You probably need to adapt the last line in the configuration I posted.

EDIT: I have no clue about radicals configuration, but maybe this helps:
https://radicale.org/proxy/


#13

Ok so let me start out by saying…Thank you. I have wasted hours on this and finally everything seems to be working!!! Thank you very much.
I will try to fix those small issues with radicale next week.
I just have a few last questions, with wich you may help me understand things better.

  1. I setup seafile not using fastcgi because it said in the manual that it is not recommende. However it is supposed to be faster & more secure. might you know why it is not recommended?
  2. What was the main reason why my setup did not work with the divided config files?
  3. can I leave the permissions I set earlier (chmod 777 for letsencrypt)?
  4. Am I missing any further security precausions?

Thank you again for all your help!


#14

Glad it works as it should :slight_smile:

Regarding your questions:

  1. fastcgi is not supported anymore since Seafile 6.3(?) - Seafile uses now WSGI
  2. the main reason was, that a combination of server_name and listen directive in nginx configuration has to be unique which wasn’t the case in your configuration:
    nginx: [warn] conflicting server name "bla.no-ip.de" on 0.0.0.0:80, ignored
    Maybe additionaly I also changed some minor things - can’t remember exactly what I did and I am to lazy to compare my posted configuration with your old one again.
  3. I would definitively change the permissions of the letsencrypt certificate back to quite paranoid settings, because there are private keys in there! The webserver needs to read that directory, letsencrypt client needs to be able to read+write in there.
  4. I would recommend to adapt your nginx configuration to that (sorry, only in german): https://www.sherbers.de/howto/nginx/
    Then I would also get radicale to work through nginx as reverse proxy (make access to radicale working via https://bla.no-ip.de/radicale/) and then also close that port 9175 radicale is using. The less ports are open to the outer world the better. And nginx is probably better tested, more secure and retrieves faster fixes than radicale.
    Additionaly you could configure fail2ban to ban bruteforce attacks against seafile (https://manual.seafile.com/security/fail2ban.html).
    And keep your system up to date - it is reachable from the internet, so it will be attacked rather sooner than later. This is a fact!

#15

Offtopic:

I never get anything except ssh brute force attacks. So I really don’t know why everyone is making so much trouble around it, of course I made everything very secure but why everyone has so much fear?