Problème de redirection (redirect_ynh)



Je viens de configurer mon serveur avec plusieurs applications et je rencontre des soucis de redirections. Voilà la situation avant le “bug”

  • ndd.tld > renvoie vers interface admin
  • www.ndd.tld > renvoie vers interface admin
  • wiki.ndd.tld > renvoi vers dokuwiki
  • rss.ndd.tld > renvoi vers ttrss

cette situation ne conveniat pas car je souhaitais plutot avoir un résultat qui ressemble à ça

  • ndd.tld > renvoie vers wiki
  • www.ndd.tld > renvoie vers wiki
  • wiki.ndd.tld > renvoi vers dokuwiki
  • rss.ndd.tld > renvoi vers ttrss

j’ai donc utiliser l’application redirect_ynh et mis en place 2 redirections

  • ndd.tld > wiki.ndd.tld (1)
  • www.ndd.tld > wiki.ndd.tld (2)

la redirection (2) a bien fonctionné, par contre la (1) me pose des soucis car je perds l’accès à l’interface user (l’interface admin fonctionne bizarrement) et aux sous-domaines

en gros voilà ma situation

  • ndd.tld > wiki.ndd.tld et plus accès interface user
  • www.ndd.tld > wiki.ndd.tld (ok)
  • wiki.ndd.tld > renvoi vers dokuwiki (ok)
  • rss.ndd.tld > wiki.ndd.tld (nok)

Comment résoudre ce problème ?
Je pense supprimer tout d’abord la redirection (1)
Par contre, je ne sais pas comment contourner le problème ? des idées ?


Dans ynh tu as un “domaine principal” qui gère le portail utilisateur. On dirait ndd.tld chez toi. Or, si sur ndd.tld tu fais une redirection 301/302 permanente, je pense qu’il ne trouve plus le portail.

Une solution serait de changer dans l’interface admin ou la console le domain ee principal en wiki.ndd.tld
Ou sinon de faire des redirections proxy si ton wiki le permet (ou bien en dur tu peux juste copier coller a peu près le nginx de dokuwiki)


Bingo, tu as vu juste

J’ai finalement créer un admin.ndd.tld que j’ai mis en domaine principale

le problème de redirection semble maintenant résolu, par contre le sso ne semble plus fonctionner avec certaines applications :frowning:


et j’ai un souci de certificat avec mon mail maintenant …


Can you explain the issue in English?


Hi @kanhu,

Well, I will try to explain.

At the beginning, the situation was like this

  • ndd.tld > goes to the admin interface
  • www.ndd.tld > goes to the admin interface
  • wiki.ndd.tld > goes to a dokuwiki
  • rss.ndd.tld > goes to ttrss

I was trying to have something like this

  • ndd.tld > goes to wiki.ndd.tld
  • www.ndd.tld > goes to wiki.ndd.tld
  • wiki.ndd.tld > goes to a dokuwiki
  • rss.ndd.tld > goes to ttrss

That is why, I created 2 redirection with redirect_ynh

  • ndd.tld > wiki.ndd.tld (1)
  • www.ndd.tld > wiki.ndd.tld (2)

The (2) works well whereas (1) makes problem.

  • I could not connect to the user interface
  • I could not access ttrss and other applications

@scith found out why it was not working. The reason was that ndd.tld was set as the default domain.
That is why, I created a new sub-domain admin.ndd.tld and set it as the default domain. Now, I note that :

  • I can access to the user interface
  • sso does not work well (not working with nextcloud, dokuwiki; ok with ttrss)
  • when I try to look at my mail (user@ndd.tld) with thunderbird, I have an error because of a certificat problem (all my domain/sub-domain are well configured with let’s encrypt)

I hope it is more clear for you now


Perhaps another idea, although it may be more like a “hack”…
Install the redirect on ndd.TLD not on the root but in a path like ndd.TLD/wiki
In the admin interface, set the default application for ndd.TLD as the wiki redirect.

Now, when users go to ndd.TLD, they will be redirected to ndd.TLD/wiki and then wiki.ndd.TLD automatically.
However, your ndd.TLD will remain intact for the SSO, the mail or other stuff.

This won’t solve the root of the issue, but it may solve your specific problems for now…

Perhaps it could also be a problem in the redirect app… I saw this :
Could you perhaps try to change the nginx conf file into
location ~ ^/$ {

Then save and reload nginx: sudo service nginx reload

What this would perhaps do is redirect only ndd.TLD but not ndd.TLD/yunohost or else


The redirect app should be improved. But if you are comfortable with manual configuration I can help.

  1. Make ndd.tld as your default domain again.
  2. Remove all the redirects.
  3. Edit etc/ssowat/conf.json.persistent and add "portal_domain": "admin.ndd.tld",
  4. Do $yunohost app ssowatconf
  5. Add ndd.tld and www.ndd.tld with $ yunohost domain add DOMAIN.TLD
  6. Install lets encrypt for both the domains i.e. ndd.tld and www.ndd.tld
    7.Go to etc/nginx/conf.d/ndd.tld.d
  7. Add a text file redirect.conf and insert these lines.

location / {

return 301 $scheme://wiki.ndd.tld$request_uri;

8. Do same steps www .ndd.tld
9. Do $service nginx restart


thank you @kanhu, @scith

@kanhu, I think I can do what you suggest. What bothers me is that I am not sure to be able to modify those files myself the day I decide to change something on my server…

Before following your advice, I would like to ask one question.

Is it possible to configure the redirection in order to redirect ndd.tld and www.ndd.tld to the wiki but to keep ndd.tld/www.ndd.tld shown in the browser url (I hope you can understand what I mean)


No it is not. Redirection itself means taking you other address. What do you want to do is alias address, which is app based like in nextcloud you can define two domain presenting same nextcloud instances. This is not Yunohost limitation.

But still you can try it through nginx configuration, some apps might work. My typical example is Zeronet. I have two domain for it. One for normal internet other for TOR.

You will have to copy the nginx configuration of /etc/nginx/config.d/wiki.ndd.tld.d/dokuwiki.config to /etc/nginx/config.d/www.ndd.tld.d/dokuwiki.config and /etc/nginx/config.d/ndd.tld.d/dokuwiki.config. Then restart nginx. This may work if Dokuwiki is ok with the alias address.


I disagree. It is possible by using the “proxy” setting in redirect_ynh.
But that wouldn’t be optimal.
The best would be to replace the nginx file with the exact same nginx used for wiki.ndd.TLD.
This way, both domains will behave the same.

This is supposing that the wiki accepts such behavior, which is perhaps @Kahnu point?



I tried the “proxy setting” in redirect_ynh.

when I try to browse ndd.tld or www.ndd.tld, I get a “502 Bad Gateway” :frowning:


Then Kahnu is right :smiley:
Unless you try to customize the nginx conf file, I guess you are stuck with the “hack” then


I followed your instruction, and now I can not access to my website " 500 Internal Server Error"
However, redirection are working


You need to tell which of the website is giving 500 internal server error.

You can check the nginx log for the that website by:

$ tail -n 100 /var/logs/nginx/domain.tld.error.log


Hi @kanhu

the entire website returns 500 internal error (domain and sub-domain)

you can look at the log here


Restart the server.

  1. Show me the configuration etc/ssowat/conf.json.persistent and the nginx file you edited.



here is the result



I think you should respect the json syntax.There should be “,” after “redirected_urls”: {}. So the conf.json.persistance should be:

    "redirected_urls": {},
    "portal_domain" : ""