Nginx Related Tips and Configurations
This page contains all the information you'll ever need regarding nginx and how to work with it in both a production and development/static enviroment.
Noteable Nginx Points
For nginx, On most systems, The config can be found in /etc/nginx
& virtual hosts are present in:
/etc/nginx/conf.d
- CentOS/RHEL/AlmaLinux/RockyLinux Based systems/etc/nginx/sites-available
- Debian/Ubuntu Based systems
Things to know:
- File names must end in a
.conf
as by default, thenginx.conf
(the parent file) only sees .conf files (*.conf - setting). - Files placed inside
sites-available
must be system linked usingln
command tosites-enabled
as by default, thenginx.conf
(the parent file) only sees the.conf
files present insidesiltes-enabled
and notsites-available
.
Basic Nginx Config
This is the most basic nginx config where proxy_pass
& server_name
values need to be modified and it should work in most applications. This config already passes the real IP in the proxy_set_header
value and it can be commented out by putting a #
in the beginning of the line to disable.
server { listen 80; server_name www.example.com example.com; location / { proxy_pass http://localhost:2000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Forwarded-For $remote_addr; } }
Creating phpinfo() page
The phpinfo()
function in php outputs a number of important but compromizing details about the php enviroment that the script is running on. It can be used to troubleshoot or fetch info about the server. This script can be simply made by creating a file with any name with the .php
extension & putting then following into it:
<?php
phpinfo( );
?>
After this, Navigate to the URL and the phpinfo()
page should open.