So, with this configuration, it's ok !
<VirtualHost *:80>
ServerName mydomain.com
ServerAdmin
[email protected]
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^[^\/]*\/(.*) https://mydomain.com/$1 [R=301,L]
</IfModule>
RewriteCond %{SERVER_NAME} =mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:4567>
ServerName subdomain.mydomain.com
# Basic security headers
Header always set X-Content-Type-Options "nosniff"
Header always set X-Xss-Protection "1; mode=block"
# NodeBB header
RequestHeader set X-Forwarded-Proto "https"
# Static file cache
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css)$">
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 14 days"
Header set Cache-Control "public"
</IfModule>
</FilesMatch>
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
# Custom Error Document when NodeBB is offline
ProxyPass /error-documents !
ErrorDocument 503 /error-documents/503.html
Alias /error-documents path/to/nodebb/public
# Websocket passthrough
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:4567/$1 [P,L]
ProxyPass / http://localhost:4567/
ProxyPassReverse / http://localhost:4567/
# Log stuff
ErrorLog ${APACHE_LOG_DIR}/nodebb-error.log
CustomLog ${APACHE_LOG_DIR}/nodebb-access.log combined
RewriteCond %{SERVER_NAME} =subdomain.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
The problem is that I had not put 2 different ServerName in the config, so all traffic was redirected and rewritten in HTTPS on the same ServerName : subdomain.mydomain.com