Skip to content

Instantly share code, notes, and snippets.

@ankurk91
Last active June 23, 2025 05:18
Show Gist options
  • Select an option

  • Save ankurk91/d6bb80692bb72c169f15c08985df85f6 to your computer and use it in GitHub Desktop.

Select an option

Save ankurk91/d6bb80692bb72c169f15c08985df85f6 to your computer and use it in GitHub Desktop.

Revisions

  1. ankurk91 revised this gist Jun 23, 2025. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -56,4 +56,5 @@ http {

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
    #add_header X-Robots-Tag "noindex, nofollow" always;
    }
  2. ankurk91 revised this gist Jun 23, 2025. 2 changed files with 17 additions and 17 deletions.
    29 changes: 14 additions & 15 deletions laravel-nginx.conf
    Original file line number Diff line number Diff line change
    @@ -1,37 +1,36 @@
    # /etc/nginx/sites-enabled/laravel.conf

    server {
    listen 80;

    # listen 443 ssl;
    # ssl_certificate /etc/nginx/certs/laravel.test.pem;
    # ssl_certificate_key /etc/nginx/certs/laravel.test-key.pem;

    listen [::]:80;
    server_name example.com;
    root /home/user/example.com/public;

    root /home/user-name/projects/laravel-app/public;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";

    index index.php index.html;
    index index.php;

    charset utf-8;

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    location ~ ^/index\.php(/|$) {
    fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_hide_header X-Powered-By;
    }

    access_log /var/log/nginx/example.com_access.log combined buffer=512k flush=1m;
    error_log /var/log/nginx/example.com_error.log warn;

    location ~ /\.(?!well-known).* {
    deny all;
    }

    access_log /var/log/nginx/example.com_access.log combined buffer=512k flush=1m;
    error_log /var/log/nginx/example.com_error.log warn;
    }
    }
    5 changes: 3 additions & 2 deletions node-js-nginx.conf
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    # /etc/nginx/sites-enabled/node-js.conf

    server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    @@ -33,5 +35,4 @@ server {
    deny all;
    }

    }

    }
  3. ankurk91 revised this gist Jun 18, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions laravel-nginx.conf
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ server {

    root /home/user-name/projects/laravel-app/public;

    index index.php;
    index index.php index.html;

    charset utf-8;

    @@ -22,8 +22,8 @@ server {
    error_page 404 /index.php;

    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    include fastcgi_params;
    }
  4. ankurk91 revised this gist Jun 4, 2025. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions laravel-nginx.conf
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,9 @@ server {
    # ssl_certificate /etc/nginx/certs/laravel.test.pem;
    # ssl_certificate_key /etc/nginx/certs/laravel.test-key.pem;

    server_name laravel.test *.laravel.test;
    server_name example.com;

    root /home/ankur/projects/laravel-app/public;
    root /home/user-name/projects/laravel-app/public;

    index index.php;

    @@ -32,6 +32,6 @@ server {
    deny all;
    }

    error_log /var/log/nginx/laravel.test_error.log;
    access_log /var/log/nginx/laravel.test_access.log;
    access_log /var/log/nginx/example.com_access.log combined buffer=512k flush=1m;
    error_log /var/log/nginx/example.com_error.log warn;
    }
  5. ankurk91 revised this gist Jun 4, 2025. 4 changed files with 38 additions and 27 deletions.
    File renamed without changes.
    2 changes: 1 addition & 1 deletion nginx.conf
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ include /etc/nginx/modules-enabled/*.conf;

    events {
    worker_connections 768;
    # multi_accept on;
    multi_accept on;
    }

    http {
    37 changes: 37 additions & 0 deletions node-js-nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    # /etc/nginx/sites-enabled/node-js.conf

    server {

    server_name example.com;

    location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_cache_bypass $http_upgrade;

    # Proxy headers
    proxy_set_header Host $host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    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;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;

    # Proxy timeouts
    proxy_connect_timeout 60s;
    proxy_send_timeout 60s;
    proxy_read_timeout 60s;

    }

    access_log /var/log/nginx/example.com_access.log combined buffer=512k flush=1m;
    error_log /var/log/nginx/example.com_error.log warn;

    location ~ /\.(?!well-known).* {
    deny all;
    }

    }

    26 changes: 0 additions & 26 deletions node-js-project.conf
    Original file line number Diff line number Diff line change
    @@ -1,26 +0,0 @@
    server {

    server_name example.com;

    location / {
    proxy_pass http://localhost:3000;
    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;

    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;
    }

    access_log /var/log/nginx/example.com_access.log;
    error_log /var/log/nginx/example.com_error.log;

    location ~ /\.(?!well-known).* {
    deny all;
    }

    }

  6. ankurk91 revised this gist Jun 1, 2025. 2 changed files with 2 additions and 8 deletions.
    5 changes: 1 addition & 4 deletions laravel-project.conf
    Original file line number Diff line number Diff line change
    @@ -19,9 +19,6 @@ server {
    try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
    @@ -36,5 +33,5 @@ server {
    }

    error_log /var/log/nginx/laravel.test_error.log;
    access_log /var/log/nginx/laravel.test_access.log combined;
    access_log /var/log/nginx/laravel.test_access.log;
    }
    5 changes: 1 addition & 4 deletions node-js-project.conf
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ server {
    server_name example.com;

    location / {
    proxy_pass http://localhost:5010;
    proxy_pass http://localhost:3000;
    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;
    @@ -15,9 +15,6 @@ server {
    proxy_cache_bypass $http_upgrade;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }

    access_log /var/log/nginx/example.com_access.log;
    error_log /var/log/nginx/example.com_error.log;

  7. ankurk91 revised this gist Jun 1, 2025. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;
    error_log /var/log/nginx/error.log;
    include /etc/nginx/modules-enabled/*.conf;

    events {
    @@ -41,15 +42,13 @@ http {
    # Logging Settings
    ##

    #access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_static on;

    ##
    # Virtual Host Configs
  8. ankurk91 revised this gist Jun 1, 2025. No changes.
  9. ankurk91 revised this gist Jun 1, 2025. 3 changed files with 8 additions and 9 deletions.
    5 changes: 2 additions & 3 deletions laravel-project.conf
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,6 @@ server {

    root /home/ankur/projects/laravel-app/public;

    add_header X-Frame-Options "SAMEORIGIN";

    index index.php;

    charset utf-8;
    @@ -27,7 +25,8 @@ server {
    error_page 404 /index.php;

    location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    include fastcgi_params;
    }
    4 changes: 2 additions & 2 deletions node-js.conf → node-js-project.conf
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@ server {
    server_name example.com;

    location / {
    proxy_pass http://localhost:5010;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://localhost:5010;
    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;

    8 changes: 4 additions & 4 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Install on Ubuntu 20/22/24
    # Install on Ubuntu 22/24

    ### Cleanups

    @@ -24,8 +24,8 @@ sudo systemctl enable nginx
    Hope you have already installed the php-cli, lets install the glue now

    ```bash
    sudo apt install php8.3-fpm
    sudo systemctl start php8.3-fpm
    sudo apt install php8.4-fpm
    sudo systemctl start php8.4-fpm
    ```

    ### Ngnix service commands
    @@ -47,7 +47,7 @@ sudo systemctl reload nginx
    You can tweak `php.ini` at this location

    ```
    /etc/php/8.3/fpm/php.ini
    /etc/php/8.4/fpm/php.ini
    ```

    ### Links
  10. ankurk91 revised this gist May 31, 2025. 1 changed file with 29 additions and 0 deletions.
    29 changes: 29 additions & 0 deletions node-js.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    server {

    server_name example.com;

    location / {
    proxy_pass http://localhost:5010;
    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;

    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;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }

    access_log /var/log/nginx/example.com_access.log;
    error_log /var/log/nginx/example.com_error.log;

    location ~ /\.(?!well-known).* {
    deny all;
    }

    }

  11. ankurk91 revised this gist May 31, 2025. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions laravel-project.conf
    Original file line number Diff line number Diff line change
    @@ -35,4 +35,7 @@ server {
    location ~ /\.(?!well-known).* {
    deny all;
    }

    error_log /var/log/nginx/laravel.test_error.log;
    access_log /var/log/nginx/laravel.test_access.log combined;
    }
  12. ankurk91 revised this gist Nov 4, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Install on Ubuntu 20/22
    # Install on Ubuntu 20/22/24

    ### Cleanups

  13. ankurk91 revised this gist Jul 6, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,7 @@ sudo apt remove "libapache2-mod-php*"
    ### Install Nginx

    ```bash
    sudo add-apt-repository ppa:ondrej/nginx -y
    sudo apt update
    sudo apt install nginx -y
    sudo systemctl enable nginx
  14. ankurk91 revised this gist Mar 15, 2024. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -23,8 +23,8 @@ sudo systemctl enable nginx
    Hope you have already installed the php-cli, lets install the glue now

    ```bash
    sudo apt install php8.2-fpm
    sudo systemctl start php8.2-fpm
    sudo apt install php8.3-fpm
    sudo systemctl start php8.3-fpm
    ```

    ### Ngnix service commands
    @@ -46,7 +46,7 @@ sudo systemctl reload nginx
    You can tweak `php.ini` at this location

    ```
    /etc/php/8.2/fpm/php.ini
    /etc/php/8.3/fpm/php.ini
    ```

    ### Links
  15. ankurk91 revised this gist Dec 28, 2022. 2 changed files with 2 additions and 1 deletion.
    1 change: 1 addition & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,7 @@ http {
    keepalive_timeout 65;
    types_hash_max_size 2048;
    server_tokens off;
    client_max_body_size 100M;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;
    2 changes: 1 addition & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Install on Ubuntu 20
    # Install on Ubuntu 20/22

    ### Cleanups

  16. ankurk91 revised this gist Dec 10, 2022. 2 changed files with 4 additions and 4 deletions.
    2 changes: 1 addition & 1 deletion laravel-project.conf
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ server {
    error_page 404 /index.php;

    location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    include fastcgi_params;
    }
    6 changes: 3 additions & 3 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -23,8 +23,8 @@ sudo systemctl enable nginx
    Hope you have already installed the php-cli, lets install the glue now

    ```bash
    sudo apt install php8.1-fpm
    sudo systemctl start php8.1-fpm
    sudo apt install php8.2-fpm
    sudo systemctl start php8.2-fpm
    ```

    ### Ngnix service commands
    @@ -46,7 +46,7 @@ sudo systemctl reload nginx
    You can tweak `php.ini` at this location

    ```
    /etc/php/8.1/fpm/php.ini
    /etc/php/8.2/fpm/php.ini
    ```

    ### Links
  17. ankurk91 revised this gist Sep 16, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -52,4 +52,5 @@ You can tweak `php.ini` at this location
    ### Links
    * https://github.com/h5bp/server-configs-nginx
    * https://www.digitalocean.com/community/tools/nginx
    * https://www.serverion.com/nginx-config/
    * https://www.serverion.com/nginx-config/
    * https://www.cloudbooklet.com/install-phpmyadmin-on-ubuntu-20-04-with-nginx/
  18. ankurk91 revised this gist Sep 16, 2022. No changes.
  19. ankurk91 revised this gist Sep 16, 2022. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,6 @@ sudo apt remove "libapache2-mod-php*"
    ```bash
    sudo apt update
    sudo apt install nginx -y
    sudo ufw allow in "Nginx"
    sudo systemctl enable nginx
    ```

  20. ankurk91 revised this gist Mar 2, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion laravel-project.conf
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ server {
    error_page 404 /index.php;

    location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
    fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    include fastcgi_params;
    }
  21. ankurk91 revised this gist Mar 2, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -24,8 +24,8 @@ sudo systemctl enable nginx
    Hope you have already installed the php-cli, lets install the glue now

    ```bash
    sudo apt install php8.0-fpm
    sudo systemctl start php8.0-fpm
    sudo apt install php8.1-fpm
    sudo systemctl start php8.1-fpm
    ```

    ### Ngnix service commands
    @@ -47,7 +47,7 @@ sudo systemctl reload nginx
    You can tweak `php.ini` at this location

    ```
    /etc/php/8.0/fpm/php.ini
    /etc/php/8.1/fpm/php.ini
    ```

    ### Links
  22. ankurk91 revised this gist Dec 1, 2021. No changes.
  23. ankurk91 revised this gist Dec 1, 2021. 3 changed files with 153 additions and 1 deletion.
    38 changes: 38 additions & 0 deletions laravel-project.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    # /etc/nginx/sites-enabled/laravel.conf

    server {
    listen 80;

    # listen 443 ssl;
    # ssl_certificate /etc/nginx/certs/laravel.test.pem;
    # ssl_certificate_key /etc/nginx/certs/laravel.test-key.pem;

    server_name laravel.test *.laravel.test;

    root /home/ankur/projects/laravel-app/public;

    add_header X-Frame-Options "SAMEORIGIN";

    index index.php;

    charset utf-8;

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
    deny all;
    }
    }
    59 changes: 59 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    # /etc/nginx/nginx.conf

    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;
    include /etc/nginx/modules-enabled/*.conf;

    events {
    worker_connections 768;
    # multi_accept on;
    }

    http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    #access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_static on;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
    }
    57 changes: 56 additions & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,56 @@
    # Install
    # Install on Ubuntu 20

    ### Cleanups

    :warning: If you have already installed apache, you must uninstall it

    ```bash
    sudo systemctl stop apache2.service
    sudo apt remove apache2
    sudo apt remove "libapache2-mod-php*"
    ```

    ### Install Nginx

    ```bash
    sudo apt update
    sudo apt install nginx -y
    sudo ufw allow in "Nginx"
    sudo systemctl enable nginx
    ```

    ### Configure Nginx for PHP

    Hope you have already installed the php-cli, lets install the glue now

    ```bash
    sudo apt install php8.0-fpm
    sudo systemctl start php8.0-fpm
    ```

    ### Ngnix service commands

    * Check for syntax errors

    ```bash
    sudo nginx -t
    ```

    * Reload after updating the configurations

    ```bash
    sudo systemctl reload nginx
    ```

    ### Tweak php.ini

    You can tweak `php.ini` at this location

    ```
    /etc/php/8.0/fpm/php.ini
    ```

    ### Links
    * https://github.com/h5bp/server-configs-nginx
    * https://www.digitalocean.com/community/tools/nginx
    * https://www.serverion.com/nginx-config/
  24. ankurk91 created this gist Dec 1, 2021.
    1 change: 1 addition & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    # Install