Derek Neely

...notes for thyself, but useful for all...

Apache Proxy Basic Auth to Backend Service


Apr 18, 2017 by derek


We recently needed to deploy a Docker container (Docker registry server) that requires basic auth to the backend service. The standard Apache config for proxying back to the Docker container worked fine for pushing and pulling images and browser based stuff we were doing.

ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/

However, the issue we wound up having was tying in the registry APIs to a little tool kit we run to help visualize and browse the repositories and images we have on our registry. The issue we were having is we were unable to pass through the basic auth needed due to the initial OPTIONS request that is made when sending the Authorization header. So, besides the additional CORS stuff we had to enable in the Apache config we also needed to handle the proxying a little differently.

RewriteEngine  On
RewriteCond %{REQUEST_METHOD} !=OPTIONS
RewriteRule /(.*)  http://127.0.0.1:5000/$1 [P,L]
ProxyPassReverse / http://127.0.0.1:5000/

If you have any questions or need help, feel free to ping me on Twitter.

Security, Proxy, Web, Apache

Social


Tweet Tweet Tweet


© 2016 Derek Neely