Create subdomain to docker container

I have installed Rainloop docker container on port 9001 and with a map volume from “/rainloop/data” to “/home/webmail.domain.dk/public_html/Data”. The container is running. When I open https://[My IP]:9001 it is working. I have followed the following article:

To get webmail.domain.dk to point to [My IP]:9001 I have changed the file /usr/local/lsws/conf/httpd_config.conf so the following is inserted:

extprocessor webmail.domain.dk {
  type                    proxy
  address                 [My IP]:9001
  maxConns                100
  pcKeepAliveTimeout      60
  initTimeout             60
  retryTimeout            0
  respBuffer              0
}

I have made the following rewrite rule in .htaccess:

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
REWRITERULE ^(.*)$ https://webmail.domain.dk/$1 [P]

However it is not working. I don’t see the Rainloop login when I enter the subdomain. Instead I get a 500 message. Any ideas to what I can try to make it work?

try a different name for the extprocessor like “rainloopbackend” instead of subdomain like webmail.domain.dk

I thought that it was important that this was the same as the subdomain. If not, how does the webmail.domain.dk subsomain then knows that it should open the specific docker container at port 9001?

it’s because when you create rewriterule to subdomain it’s confusing and not referring to proxy, it’s looping back to subdomain, you can try rewriterule like this

extprocessor rainloopbackend {
  type                    proxy
  address                 [My IP]:9001
  maxConns                100
  pcKeepAliveTimeout      60
  initTimeout             60
  retryTimeout            0
  respBuffer              0
}
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^(.*)$ https://rainloopbackend/$1 [P,E=Proxy-Host:webmail.domain.dk]

Thank you very much, it seems logic to me now, that you make the reference by refering to the extprocessor name in .htaccess.

I tried your suggestion and it worked shortly, så when I go to webmail.domain.dk I could see Rainloop. But after 5 minutes it shows an 500 error again. And I can stille see it by going to [IP adress]:9001. Any suggestion to troubleshoot what is happening here?