Wrong URL to projects, users and repos after configuration on VM

Hello everyone,

I have the following configuration:

  • domain: gitlab.example.com redirect to Windows Server 2019 (IP: 10.10.10.10)
  • I have a domain with SSL to IIS along with redirecting configured in web.config
  • On the server I have a virtual machine with Ubuntu (IP: 192.168.56.105)
  • I have several applications on a virtual machine so for GitLab-CE I have assigned the port: 8181
  • I have run GitLab on VM on port 6161 (127.0.0.1:6161)

When everything is configured according to the following settings, gitlab works via WWW but when creating a group, repository or user panel instead of a domain I see the IP address of the switch to VM (192.168.56.105:8181/projects / …)

web.config in IIS:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="RewriteGitLabEncrypt" stopProcessing="true">
                    <match url="^\.well-known.*$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="RewriteGitLabRule" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />                    
                    <action type="Rewrite" url="http://192.168.56.105:8181/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

000-default.conf (Apache site enable config):

<VirtualHost *:8181>
	ServerName gitlab.example.com
	AllowEncodedSlashes NoDecode

	RewriteEngine on
	RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
	RewriteCond %{REQUEST_URI} ^/uploads/.*
	RewriteRule .* http://127.0.0.1:6161/%{REQUEST_URI} [P,QSA,NE]

	ErrorLog ${APACHE_LOG_DIR}/gitlab_error.log
	CustomLog ${APACHE_LOG_DIR}/gitlab.log combined
	CustomLog ${APACHE_LOG_DIR}/gitlab_f.log common_forwarded
</VirtualHost>

gitlab.rb

## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url 'https://gitlab.example.cm/'
nginx['enable'] = false
web_server['external_users'] = ['www-data']
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:6161"

gitlab_rails['gitlab_host'] = 'gitlab.example.cm'
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'xxx'
gitlab_rails['gitlab_email_display_name'] = 'xxx'
gitlab_rails['gitlab_email_reply_to'] = 'xxx'
gitlab_rails['gitlab_email_subject_suffix'] = ''
gitlab_rails['gitlab_default_can_create_group'] = false

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "xxx"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "xxx"
gitlab_rails['smtp_password'] = "xxx"
gitlab_rails['smtp_domain'] = "xxx"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false

What am I doing wrong?
Of course, after each change, it performs the order reconfiguration, resets apache etc.

Result:
aaaaaaaaaaaaaaaaaaaaa