Webserver configuration

Configuration details

The server has been configured to use the Nginx webserver with proxy mechanism to host multiple websites.

The hosted websites have a configuration file named domain_name in the /etc/nginx/sites-available/ directory.

In our case there are the following files

$ dataepartners.ai #accessible through URL http://dataepartners.ai default website that is hosting the Sphinx generated documentation
$ admin.dataepartners.ai #accessible through URL http://admin.dataepartners.ai website that is served by gunicorn for django apps

The hosted websites can be accessible only if they are activated/enabled under the /etc/nginx/sites-enabled/ directory.

In our case the two websites have been enabled and configured to respond to requests based on their listen and server_name directives using the following command :

$ sudo ln -s /etc/nginx/sites-available/dataepartners.ai /etc/nginx/sites-enabled/  #site http://dataepartners.ai enabled
$ sudo ln -s /etc/nginx/sites-available/dataepartners.ai /etc/nginx/sites-enabled/  #site http://admin.dataepartners.ai enabled

This has created two server blocks in the /etc/nginx/nginx.conf file.

GNU nano 6.2                     /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
  worker_connections 768;
  # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    types_hash_max_size 2048;
    # server_tokens off;

    server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text>

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;  ## all files under conf.d/ can be enabled not used in our case
    include /etc/nginx/sites-enabled/*;  ## all files under sites-enabled/ can be enabled used in our case
}

And virtual links have been added to the /etc/nginx/sites-enabled/ directory.

$ dataepartners.ai #virtual link of /etc/nginx/sites-available/dataepartners.ai
$ admin.dataepartners.ai #virtual link of /etc/nginx/sites-available/admin.dataepartners.ai

Static and dynamic websites URLs

http://dataepartners.ai gives an access to plain html website generated by Sphinx

http://admin.dataepartners.ai gives an access to dynamic website with python and postgres generated with django framework