I'm trying to deploy and setup a JHipster monolithic application as Docker Container and put it behind a NGINX with reverse-proxy and basic-auth.
version: '3.8'
services:
my-application:
image: myapplication
environment:
- _JAVA_OPTIONS=-Xmx512m -Xms256m
- SPRING_PROFILES_ACTIVE=prod,api-docs
- MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true
- SPRING_DATASOURCE_URL=jdbc:postgresql://myapplication-postgresql:5432/myapplication
- JHIPSTER_SLEEP=30 # gives time for other services to boot before the application
- SPRING_ELASTICSEARCH_REST_URIS=http://myapplication-elasticsearch:9200
ports:
- 127.0.0.1:9000:8080
The NGINX Configuration looks like this and WORKS SO FAR:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name my-application.de www.my-application.de;
access_log /var/log/nginx/reverse-access.log;
error_log /var/log/nginx/reverse-error.log;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
location / {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://127.0.0.1:9000;
proxy_set_header Authorization "";
}
location /api {
proxy_pass http://127.0.0.1:9000/api;
}
location /app {
proxy_pass http://127.0.0.1:9000/app;
}
location /management {
proxy_pass http://127.0.0.1:9000/management;
}
location /management/info {
proxy_pass http://127.0.0.1:9000/management/info;
proxy_set_header Authorization "";
}
location /i18n {
proxy_pass http://127.0.0.1:9000/i18n;
}
}
The Problem is that I must define absolutely every sub-location therewith the basic-auth works properly. I will appreciate if somebody can check the setting and says how can I adjust the configuration to cover all locations and sub-locations.