A simple authentication proxy for HTTP BasicAuth endpoints
- Documentation:
- Host System adjustments:
- Add user:
auth-proxy
:sudo adduser --system --group --no-create-home --home /opt/auth-proxy auth-proxy
- Add folders with owner and group
auth-proxy
: /var/log/auth-proxy/
/opt/auth-proxy
- Add user:
- Build application with
mvn install
- Copy
*.jar
from./target/
folder toHost System:/opt/auth-proxy/
- Create symlink to generic
auth-proxy.jar
:sudo ln -sv /opt/auth-proxy/auth-proxy-0.0.1-SNAPSHOT.jar /opt/auth-proxy/auth-proxy.jar
- Create symlink in
/etc/init.d
with nameauth-proxy
. - Create
/opt/auth-proxy/auth-proxy.conf
with the following content:MODE=service JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom" RUN_ARGS="--server.servlet.contextPath=/auth-proxy --logging.file=/var/log/auth-proxy/auth-proxy.log"
- Test service via
sudo /etc/init.d auth-proxy start|status|stop
- Activate service on system level:
sudo update-rc.d auth-proxy defaults
- Restart host system and check log if service is running:
sudo tail -f /var/log/auth-proxy/auth-proxy.log
- Enable logrotation via
/etc/logrotate.d/auth-proxy
:/var/log/auth-proxy/auth-proxy.log { copytruncate weekly rotate 52 compress missingok create 640 auth-proxy auth-proxy }
- Configure proxy in nginx via
/etc/nginx/sites-enabled/envirocar
(similar to docker nginx config)[...] upstream auth-proxy { server 127.0.0.1:9999 fail_timeout=0; } [...] location /auth-proxy { proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto https; proxy_redirect off; proxy_connect_timeout 240; proxy_send_timeout 240; proxy_read_timeout 240; proxy_pass http://auth-proxy; } [...]