I am having troubles setting-up apache
.
Applications:
application 1 - SPA (frontend), running in docker. Accessible locally by http://localhost:91
application 2 - WebAPI (backend service), running in docker. Accessible locally by http://localhost:90
I would like to make both applications available on the same domain via HTTPS using apache
:
- application 1:
https://my.domain.com
<- should be secured with basic auth.
- application 2:
https://my.domain.com/api
I thought I had this set-up working when I used plain HTTP to access the recourses, but once I switched to HTTPS (self-signed
with letsencrypt
) - everything seems to have stopped working.
here is the latest configuration
<VirtualHost *:80>
ServerName my.domain.com
ServerAlias www.my.domain.com
TraceEnable off
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.my.domain.com [OR]
RewriteCond %{SERVER_NAME} =my.domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName my.domain.com
ServerAlias www.my.domain.com
TraceEnable off
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
#Allow from all
Allow from 127.0.0.1
</Proxy>
Timeout 2400
ProxyTimeout 2400
ProxyBadHeader Ignore
<Location />
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
ProxyPass http://localhost:91/ Keepalive=On
ProxyPassReverse http://localhost:91/
</Location>
<Location /api>
ProxyPass http://localhost:90/
ProxyPassReverse http://localhost:90/
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/my.domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/my.domain.com/privkey.pem
</VirtualHost>
</IfModule>
The latest and current problem is:
Whenever I try to access the endpoint https://my.domain.com/api/Auth/Login
- user is prompted with login page. This should only be valid for non-api urls.
In other words - <Location /api>
directive seems to be ignored. I have tried shuffling location directives around as well as dozen of other solutions and none of them work.. I also tried more explicit directive like <LocationMatch /(api).*>
that also failed to work.
Is there something wrong with location matching rules?