Nginx Configuration

This guide should help you set up and configure Nginx, customize the server block to match your requirements, and update your application's .env file to reflect the changes.

Installing Nginx

To install Nginx, you can use the apt package manager. Simply open a terminal and run the following commands:

sudo apt update
sudo apt install nginx

Use the following steps to locate and edit the .env file:

cd jet-onpremise
nano .env

This command will change your directory to the location where the .env file is stored and open it in the Nano text editor for editing.

Updating .env File

After navigating to the .env file, update your application's .env file with the appropriate domain names. Replace localhost with your custom domain across the relevant variables:


Use the following command to navigate to the directory where the Nginx configuration files are stored:

cd /etc/nginx/conf.d

Updating Nginx Configuration:

Open the Nginx configuration file in a text editor, such as Nano:

sudo nano your_configuration_file

Nginx Configuration

Below is an example configuration for Nginx server block. This configuration handles HTTPS requests, proxying them to a jet-onpremise_nginx running on port 8080. Adjust the paths and server names to match your setup.

server {
    listen 80 default_server;
    server_name _; 
    return 301 https://$host$request_uri;

server {
    listen 443 http2 ssl;
    ssl_certificate /etc/ssl/certs/;     # Note: Replace with your domain
    ssl_certificate_key /etc/ssl/certs/; # Note: Replace with your domain
    server_name, ...;  #Your server names

    client_max_body_size 32m;
    add_header 'Strict-Transport-Security' 'max-age=0;';
    merge_slashes off;
    large_client_header_buffers 4 32k;

    location / {
        proxy_hide_header 'Access-Control-Allow-Origin';
        proxy_hide_header 'Access-Control-Allow-Methods';
        proxy_hide_header 'Access-Control-Allow-Headers';
        proxy_hide_header 'Access-Control-Expose-Headers';

        add_header 'Access-Control-Allow-Origin' '*' always;
        add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,X-HTTP-Method-Override,X-Bridge-Settings,X-Stick-Session';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range,Content-Disposition,Content-Type';
        add_header 'Strict-Transport-Security' 'max-age=0;';
        access_log off;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffer_size 128k;
        proxy_buffers 8 128k;
        proxy_busy_buffers_size 128k;

Replace with your domain

To check the configuration and reload the Nginx configuration, you can use the following commands:

nginx -t                   # Check configuration syntax
nginx -s reload            # Reload Nginx configuration


After updating the .env file, verify the changes by accessing your application through the new custom domain in a web browser. If configured correctly, your application should now be accessible via the updated domain names.

Note: Don't forget to replace with your actual domain name in both the Nginx configuration and the .env file. Additionally, ensure that SSL certificates are correctly configured for your domain to enable secure HTTPS connections.

If you would like to use certificates from "Let's Encrypt", you can refer to this documentation:

Link: Let's Encrypt Certbot Instructions

Last updated