Skip to main content

In an environment that is running

  • Ubuntu 20.02
  • Nginx
  • Solr

 

The default Nginx conf is located /etc/nginx/sites-available/ and contains something similar to:


server {
    listen      80;
    listen [::]:80;
    server_name uat.oursite.com;
    return      301 http://uat.oursite.com$request_uri;
}

server {
    listen 80;
    listen [::]:80;
    listen 443 ssl;
    ssl_certificate /etc/ssl/certs/Bundle.crt;
    ssl_certificate_key /etc/ssl/private/MultidomainWildcard.key;

    # Security headers
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";

    root /var/www/html/oursite;
    index  index.php index.html index.htm;
    server_name  uatweb.oursite.com;

    # Redirect HTTP to HTTPS
    if ($scheme = http) {
        return 301 https://$server_name$request_uri;
    }

    location / {
        try_files $uri /index.php?$query_string;
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    location ~ [^/]\.php(/|$) {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ ^/sites/.*/files/styles/ {
        try_files $uri @rewrite;
    }

    location ~ ^(/[a-z\-]+)?/system/files/ {
        try_files $uri /index.php?$query_string;
    }

    location ~* "^/Archived-Reports/Projects/(.*)" {
        return 301 /sites/default/files/products/$1;
    }

}

 

To include Solr in to this configuration, the following lines need to be added

location /solr/ {
    proxy_pass http://127.0.0.1:8983/solr/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

 

Verify Proxy Configuration: Ensure that the Nginx server is correctly forwarding requests to Solr. Check the Nginx error log for any potential issues:

sudo tail -f /var/log/nginx/error.log

Solr on 127.0.0.1:8983: Confirm that your Solr server is running on 127.0.0.1:8983. If your Solr instance is running on a different host or port, you may need to adjust the proxy_pass directive in the Nginx configuration accordingly.

 

Test Nginx Configuration

Before restarting Nginx, test the configuration to make sure there are no syntax errors:

sudo nginx -t

 

Nginx Restart

After making changes to the Nginx configuration, make sure to restart Nginx to apply the changes:

sudo systemctl restart nginx

 

Solr page

Normally to access the respective Solr page, would be

https://uat.your-site.com:8983/solr/

In this instance it is

https://uat.your-site.com/solr/

 

Related articles

Andrew Fletcher18 Mar 2024
Resolving CVE-2022-48624 less issue
To resolve the CVE-2022-48624 vulnerability on Ubuntu using Nginx, it's crucial to understand that the issue lies within the "less" package, not Nginx itself. The vulnerability affects "less" before version 606, where close_altfile in filename.c in less omits shell_quote calls for LESSCLOSE,...
Andrew Fletcher06 Mar 2024
Terminal command to find and replace
In many terminal text editors, you use find command as reference in Terminal commands - find.  How about find and replace.  This action depends on the specific text editor you're using in the terminal.  Here are a few common terminal text editors and how you can find and replace...