Sunday, November 28, 2021

Accessing DSpace with a Subdomain


In this blog post, we learn how to map DSpace digital repository installed on a VPS/cloud server with a subdomain creating VirtualHost in the Nginx webserver. 

Install Nginx web server.

sudo apt install nginx -y

Create an Nginx server block configuration file for the subdomain.

sudo nano /etc/nginx/conf.d/

Fill in the configuration.

server {
    listen 80;
    access_log /var/log/nginx/;
    error_log /var/log/nginx/;

    root /opt/tomcat/webapps/;
    client_max_body_size 100M;

    location / {
        return 301 /xmlui;

    location /xmlui {
        index index.jsp;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:8080/xmlui;
        proxy_redirect  http://localhost:8080/xmlui;

        proxy_buffering off;
        proxy_store     off;

        proxy_connect_timeout 120;
        proxy_send_timeout    120;
        proxy_read_timeout    120;

Nginx configuration test.

sudo nginx -t

If there is no error. the following will be shown

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart Nginx.

sudo systemctl restart nginx

Install SSL Let's Encrypt

Install certbot Let's Encrypt.

sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot    

SSL request for subdomain on Nginx.

sudo certbot --nginx -d

(in this you will need to provide a valid email address and agree the T&C)

If the SSL install is successful, a message appears

Congratulations! You have successfully enabled

DNS Setup

You need to create an A record in the DNS setup of your domain with your VPS/cloud server IP address  from your domain management panel (eg: Go Daddy)


No comments:

Post a Comment