I tried to configure, in any ways, redirection from a virtual server to another url outside and i always get certificate warning saying the certificate is not good and it’s for another domain (the main domain of the webmin box).
You should create an alias (via Virtualmin → Create virtual server) so that domain1 is an alias of virtual server domain2 if you intended to redirect domain1 to domain2. When you create an alias, the SSL certificates for all the domains will be handled by Virtualmin.
Note that it matters not what your main domain is and if you follow my simple suggestion to use alias domains there will be no need to look into your box - in fact your box is working exactly as it should.
Ok, but you still need to alias domain1 to domain2 and get the server which is hosting domain2 to apply for a SSL certificate for domain1 so that the lock symbol is visible when domain2 or domain1 is served.
If i dont use https, all is working and redirect properly.
when the redirection works, there is no problem… but as soon as i use https, i’m not redirected so doesnt matter if the other server would be able to handle domain1.com certificate (what would not really be possible)
Alright! Please write me a PM, describing a problem (super briefly) including actual domain names, explaining what is failing and how do you expect it to work.
Alright, I have given it a closer look. This was a bit tricky issue to fix as you have default <VirtualHost _default_:443></VirtuaHost> enabled in ssl.conf file and default certificates in /etc/pki/tls/ were used upon redirect for the virtual server in question (which is actually your hostname).
The fix I applied was to use the certificates from your default domain (your hostname) in <VirtualHost _default_:443></VirtuaHost> certificate files.
You should either not use <VirtualHost _default_:443></VirtuaHost> at all or update those SSLCertificateFile /etc/pki/tls/certs/localhost.crt and SSLCertificateKeyFile /etc/pki/tls/private/localhost.key each time it’s been updated for your hostname domain.