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:
sudoaptupdatesudoaptinstallnginx
Navigating to the .env File
Use the following steps to locate and edit the .env file:
cdjet-onpremisenano.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:
Important:
If you're deploying Nginx on the same host as onpremise, you must update the NGINX_PORT variable in the .env file:
By default, NGINX_PORT is set to 80, which conflicts with the external Nginx server that also listens on port 80. Without this change, Nginx will fail to start due to a port conflict.
Navigating to Nginx Configuration File:
Use the following command to navigate to the directory where the Nginx configuration files are stored:
Updating Nginx Configuration:
Open the Nginx configuration file in a text editor, such as Nano:
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.
Replace example.com with your domain
To check the configuration and reload the Nginx configuration, you can use the following commands:
Verification
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 example.com 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: