Secure your LA infrastructure - AtlasOfLivingAustralia/documentation Wiki


Basic measures


Ports to open from the outside

Allow basic input traffic 22/80/443 (tcp) from the outside. Restrict external access to solr web interface (port 8983).

Ports to open internally

If you want to restring the internal traffic is more complex. Initially you can open all ports between your VMs and internal IP address as a start while you discover which ports use each services and adapt it to your infrastructure.

Depending on your servers and LA software deployment you should open these TCP ports between your VMs:


If you don't need a complicated firewall configuration you can use this ansible ufw role to quickly configure the iptables in your machines.

Protect you SOLR admin interface

ssh port redirection

When you need to access to the solr admin interface (or similarly to mongo mysql or postgresql ports) from your computer, you can temporarily use ssh port redirection with something like:

ssh -L 8983: [email protected] -N -f

but this redirection is only maintained while that ssh connection is running, so it's temporary. (For many use-cases, this is adequate - you create an SSH tunnel for the brief duration of your SOLR administration tasks, then shut it down.) If you like this way to connect to your server's admin ports, you can also use other tools like autossh or sshuttle.

solr admin with apache

If you need something more permanent you can configure a vhost with basic auth like:

<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot /srv/
<Directory />
Require all granted
<Directory /srv/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
<Location />
  AuthType Basic
  AuthName "Authentication Required"
  AuthUserFile /etc/apache2/passwdfile
    Require env noauth
    Require env REDIRECT_noauth
    Require valid-user
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyRequests Off
ProxyPreserveHost On
ProxyVia full
ProxyPass / http://YOUR_INTERNAL_SOLR_SERVER:8983/
  Include /etc/letsencrypt/options-ssl-apache.conf
  SSLCertificateFile /etc/letsencrypt/live/
  SSLCertificateKeyFile /etc/letsencrypt/live/
SSLCertificateChainFile /etc/letsencrypt/live/

Using nginx to access solr

Some vhost like this should work (adapt it to your server/domain/etc):

server {
    listen 80 ;
    listen [::]:80 ;
    return 301 https://$server_name$request_uri;

server {
    listen 443 ssl  http2;
    listen [::]:443 ssl  http2;
    ssl_certificate /etc/letsencrypt/live/;
    ssl_certificate_key /etc/letsencrypt/live/;
    ssl_protocols TLSv1.3 TLSv1.2  ;
    ssl_prefer_server_ciphers on;
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_session_tickets off;
    ssl_stapling on;
    ssl_stapling_verify on;
    # Force HTTPS was configured, so setting STS value to 1 year (31536000 seconds)
    add_header Strict-Transport-Security "max-age=31536000" always;

    # Secure referrer policy to avoid leaking paths, which can include auth ticket information
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;

    # Framing security setting (Reenable using frame_options_header)
    add_header X-Frame-Options DENY always;

    root /srv/;
    index index.html;
    client_max_body_size 1024m;

    # If ssl is supported, then push this policy to all users who understand it to trigger HSTS
    add_header Content-Security-Policy upgrade-insecure-requests;

    location / {
        if ($blocked_ip) {
            return 403;
        if ($blocked_user_agent) {
            return 444;
        # proxy_set_header Host $host;
        proxy_set_header Host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;
        proxy_read_timeout 10m;
        auth_basic           "Administrator’s Area";
        auth_basic_user_file /etc/nginx/.htpasswd; 

This should be in /etc/nginx/sites-available/solr.conf (for instance) and later do:

ln -s /etc/nginx/sites-available/solr.conf /etc/nginx/sites-enabled/solr.conf
service nginx reload

Configuring a HTTP Basic Authentication.

Allowlist IP address

Some interfaces have a simple IP address allowlist system to allow some IPs to access to the administrative interface, or to use their API, etc:

More info about the /ws/ API allow listing. Take into account that this a insecure measure compared with the use apikeys over https.

Other recommendations

Use fail2ban for prevent brute force in those services (http/s and ssh authentication). If you use wordpress in your node, there is also a good fail2ban wordpress plugin that integrates well with fail2ban.

Other resources