'Problems Redirecting Apache 443 port to Nginx port 1234 for co-hosting Nextcloud and Gitlab

I have a similar problem as mentioned in Apache redirect to another port but the answer does not work for me.

I have Apache set up on an Debian VM, with an instance of Nextcloud. I setup a vhost for cloud.mydomain.com on port 443 and it works fine.

Also, I installed Gitlab on the same VM, and the external url is https://debianvm.local:1234

How can I redirect https://gitlab.mydomain.com:443 to https://debianvm.local:1234 ??

I have tried

<VirtualHost *:443>
  ServerName gitlab.mydomain.com
  ServerAlias gitlab.mydomain.com
  ProxyPass / https://debianvm:8508/

SSLEngine on
SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>

I was hoping to later be able to call certbot -d gitlab.mydomain.com and change the certificate...

I also tried putting exactly the same file for *:80 (without SSLEngine lines) and then call certbot but without success.

I also tried directly putting https://gitlab.mydomain.com in the gitlab configuration, in vain.

Any ideas?

Thanks.

On the DNS side, I set up 2 DNS redirections type A: one for cloud.mydomain.com and one for gitlab.mydomain.com, but they are pointing to the same IP.

On the port forwarding side, the NAS with the host IP is forwarding 80 and 443 to 80 and 443 of the debianvm.local



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source