List installed Modules in Nginx

To list modules compiled with nginx, you can run nginx -V nginx -V This print nginx version along with configuration used to compile nginx. If you want just the list of modules, you can use following command nginx -V 2>&1 | tr — – ‘\n’ | grep _module Example See Nginx

Nginx remove html from url

If you have a static website build using plain html files, your url will look like https://yourdomain/page.html. This .html extension is useful for the files when it is on your local computer, it help computer to associate the file with specific application, say your HTML editor. But on a web server this .html extension serve … Read more

Nginx HTTP 414 request-URI too large

Nginx Web Server

On a Nginx server, when accessing a long url, i get error HTTP 414 Request-URI Too Large To fix the error, edit vi /etc/nginx/nginx.conf inside “http” section, find large_client_header_buffers Replace the line with large_client_header_buffers 4 32k; If your URL is very large, you may need to increase the 32k to higher or reduce the url … Read more

Show Real IP Nginx Behind Reverse Proxy

Nginx Web Server

When your Nginx web server is running behind a reverse proxy, you will see IP of the reverse proxy server as visitor IP in web servers access log. To fix this, edit nginx.conf file vi /etc/nginx/nginx.conf Find http { Inside http section, add set_real_ip_from IP_ADDRESS_OF_PROXY_SERVER_HERE; real_ip_header X-Forwarded-For; Example set_real_ip_from 192.168.122.1; real_ip_header X-Forwarded-For; Restart Nginx nginx … Read more

Nginx Location Directive

Nginx Location Directive is used to route request to correct files. Match Exact match is used to match an exact URL. server { listen 80 default_server; root /var/www/html; index index.html; server_name _; location /ok/ { root /home/; } } When location is used with no modifiers, then beginning of the URL is matched. In this … Read more

Nginx Password Protect a website

nginx password protect

To password protect a website, you need to install htpasswd utility. On Ubuntu/Debian, you can install it with the command Now create a password file with the command It will ask for a password. Edit the configuration file for your website and add the following in the server entry for the website. Restart Nginx. Now … Read more

Configure Nginx to listen on single IP Address

By default Nginx listens on all IP address on a server. To make nginx listen on specific IP address, edit nginx configuration file vi /etc/nginx/nginx.conf And VirtualHost/server files for each domain located in folders /etc/nginx/conf.d => on CentOS/RHEL /etc/nginx/sites-available => on Debian/Ubuntu Find listen 80 Replace with listen IP_ADDR_HERE:80 IP_ADDR_HERE = your server IP address … Read more

Nginx Config for Laravel Application

Here is Nginx configuration for a laravel application server { listen 80; server_name www.domain.com; access_log /var/log/nginx/domain.com.log; root /home/domain.com/html/public; index index.html index.php; access_log /var/log/nginx/domain.com.log; error_log /var/log/nginx/domain.com-error.log; client_max_body_size 1000M; proxy_read_timeout 600s; fastcgi_read_timeout 600s; fastcgi_send_timeout 600s; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { try_files $uri =404; access_log off; expires max; } location = … Read more