Letsencrypt/Nxinx Redirect Error

  • Hey everyone,


    i tried installing Letsencrypt with Nextcloud with this Video:


    Everything went fine but i'm not able to connect to Nextcloud in any way. Even trying to revert the steps didnt help.
    I dont use duckdns, i registered my own domain at selfhost.de and tried to register the subdomain nextcloud.*.de there, but it doesnt seem to work.
    Do i have to change the subdomain (A-Record) to another Ip eg. XXX.XXX.XXX.XXX:444 (Nextcloud port)?


    Edit: now i get a 502 Error on my nextcloud.*.de and a "The website is currently being setup under this address." if i just try to connect to mydomain.de...


    Thanks for your help! ?(

  • Not sure how you set up letsencrypt I assume you done the config right so to setup lets say you have a nexcloud.your-domain.de


    cd to you letsencrypt config file


    cd [your config path]/Letsencrypt/nginx/proxy-confs
    open and edit nextcloud.subdomain.conf


    server {
    listen 443 ssl;


    server_name nexcloud.*;


    include /config/nginx/ssl.conf;


    client_max_body_size 0;


    location / {
    include /config/nginx/proxy.conf;
    resolver 127.0.0.11 valid=30s;
    set $upstream_nextcloud LOCALHOST_IP_OF_YOUR_SEVER;
    proxy_max_temp_file_size 2048m;
    proxy_pass https://$upstream_nextcloud:444;
    }
    }



    not sure if this will work

  • Thank you for you response: it is configured like you said, the only different thing is instead of an IP it just says nextcloud at $upstream


    edit: all sites just refer me to the index.html in the \www\ folder and i think that is the error. but how can i redirect them to the omv login page, nextcloud etc. ?

  • This is more or less how you configure nginx from your letsencrypt configuration, the problem for me I either had 502 Bag Gateway or I was hitting the nginx index.html saying something about the server the default page.


    After reading a bit of the nginx documentation, I have learnt that redirects are not actually that hard to do.


    now when you configure nextcloud subdomain or subfolder the trick that after 2 nights wasted on this config was simply solved from changing this line


    set $upstream_nextcloud nextcloud; to set $upstream_nextcloud 192.168.0.15;


    Just for reference in this case 192.168.0.15 is the local network IP of my server, because letsencrypt is on the same machine. The rest of the tutorial is the same no other things added or changed.


    Can you make your issue a bit more explicit, if you fear for privacy just change the names or censor them, unless I understand how you configured your proxy settings and your nextcloud config.php I can't provide you with any good suggestions.

  • My nextcloud.subdomain.conf looks like this:


    server {
    listen 443 ssl;


    server_name nextcloud.*;


    include /config/nginx/ssl.conf;


    client_max_body_size 0;


    location / {
    include /config/nginx/proxy.conf;
    resolver 127.0.0.11 valid=30s;
    set $upstream_nextcloud 192.168.2.110;
    proxy_max_temp_file_size 2048m;
    proxy_pass https://$upstream_nextcloud:444;
    }
    }


    But i still only get the default index.html from nginx.
    If you tell me what you need, i can post more configs or logs

  • This is the index.html i am seeing.

    It's the same you find in \Letsencrypt\www


    My default.conf looks like this:


    # main server block
    server {
    listen 443 ssl default_server;


    root /config/www;
    index index.html index.htm index.php;


    server_name *.mydomain.de;


    # enable subfolder method reverse proxy confs
    include /config/nginx/proxy-confs/*.subfolder.conf;


    # all ssl related config moved to ssl.conf
    include /config/nginx/ssl.conf;
    # enable for ldap auth
    #include /config/nginx/ldap.conf;


    client_max_body_size 0;
    location / {
    try_files $uri $uri/ /index.html /index.php?$args =404;
    }


    location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include /etc/nginx/fastcgi_params;
    }


    i think the error is in the location section. nginx tries to find index pages from nextcloud and omv, but cant access them because it's in a docker or sth. But i dont know how to fix it.

  • ok by the information you have provided so far, here is how the config files should look like.


    Navigate to your letsencrypt config folder /nginx/proxy-confs


    nano nextcloud.subdomain.conf


    paste this code



    Assuming that 192.168.2.110 is the local IP of your omv server


    Now Navigate to your nextcloud config /www/nextcloud/config


    nano config.php




    replace and add the following


    Code
    'trusted_domains' =>
    array (
    0 => '192.168.2.110:444',
    1 => 'nextcloud.domain.de',
    ),
    'overwrite.cli.url' => 'https://nextcloud.domain.de/',
    'overwritehost' => 'nextcloud.domain.de',
    'overwriteprotocol' => 'https',


    'overwrite.cli.url' already exists so remove it and replace it with the above


    after you have done this restart your letsencrypt.

  • I think you are over-complicating the config, first make it work with the simplest setup and than start piling up stuff.


    Remove from trusted_domains entry number 1,2,3,4
    Remove trusted_proxies line .


    Restart letsencrypt and nextcloud


    Access your server https://nextcloud.domain.de

  • Ok, i did that, but still only the index.html from nginx.


    Edit:
    So i think i found the error, but i dont know how to fix it. It is a nginx configuration problem.
    In my understanding, i created a docker image with /AppData/letsencrypt as root directory /config
    So nginx is trying to redirec with


    Code
    location / {
    try_files $uri $uri/ /index.html /index.php?$args =404;
    }

    and is searching for omv's and nextcloud's index.php/index.html in /config/nextcloud (which would be /AppData/letsencrypt/Nextcloud, which doesnt exist) or /config/, because it uses the URI Nextloud, and doesn't even have an URI for OMV.
    So i need to redirect it to the root Directory for Nextcloud and omv, which is outside the root path of the container.
    How can i do that? Or am i wrong?


    Thank you for your patient help!

  • Tried it again today, reinstalling everything, but still no luck... I am certain that I configure sth. wrong but I don't know what... I will have to wait I think...
    Thank you all anyways


    Update!
    It works now! No idea why it didnt work before, but after reinsalling everything a dozen times, it works now. Thank you all for your help!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!