I want to add http basic authentication on my discourse app.

When someone visits the page to throw a browser confirm dialog that will ask for username and pass.

I set up discourse through the marketplace app.

Found some docs on how to set up what I want on an Apache server: https://www.digitalocean.com/community/tutorials/how-to-set-up-password-authentication-with-apache-on-ubuntu-18-04-quickstart.

Tried following the instructions but apparently port:80 is being used from the app.

tcp6 0 0 :::80 :::* LISTEN 5820/docker-proxy

Where would I configure this for my app?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi there @akapetzoglou,

This can not be done without some configuration changes.

For example, what you could do is to change the port of the Docker container so that it binds to 8080 for example.

Then set up Apache to listen on port 80 and add a reverse proxy rule to proxy the traffic from Apache on port 80 to the Docker container on port 8080.

You can follow the steps here on how to do that:

https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension

Then you can add the basic auth rules to your Apache Vhost as normal.

Another option would be to use a firewall instead of the basic authentication. That way you can close port 80 and only allow certain IPs to access it. To do that you could either use the DigitalOcean Cloud Firewalls or use CSF for example:

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-config-server-firewall-csf-on-ubuntu

Regards,
Bobby

by Lassi Ruonavaara
Config Server Firewall (CSF) is a free and advanced firewall for most Linux distributions and Linux based VPS. Learn how to install and configure on Ubuntu.
Submit an Answer