Skip to content

Instantly share code, notes, and snippets.

@sgomez84
Last active September 4, 2023 00:34
Show Gist options
  • Select an option

  • Save sgomez84/8b86ec13dd4be8960df925cd0d34e031 to your computer and use it in GitHub Desktop.

Select an option

Save sgomez84/8b86ec13dd4be8960df925cd0d34e031 to your computer and use it in GitHub Desktop.

Revisions

  1. sgomez84 revised this gist Jan 4, 2017. 1 changed file with 14 additions and 14 deletions.
    28 changes: 14 additions & 14 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -15,8 +15,8 @@ server {

    charset utf-8;
    server_name www.sumhr.com;
    root /var/www/sumhr_wp;
    index index.php index.html index.htm;
    root /var/www/sumhr_wp;
    index index.php index.html index.htm;

    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    @@ -64,18 +64,18 @@ server {
    }

    location ~ \.php$ {
    try_files $uri =404;
    try_files $uri =404;

    # Fix for server variables that behave differently under nginx/php-fpm than typically expected
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # Include the standard fastcgi_params file included with nginx
    include /usr/local/nginx/conf/fastcgi_params;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_index index.php;
    # Override the SCRIPT_FILENAME variable set by fastcgi_params
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    # Pass to upstream PHP-FPM; This must match whatever you name your upstream connection
    fastcgi_pass phpfpm;
    }
    # Fix for server variables that behave differently under nginx/php-fpm than typically expected
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # Include the standard fastcgi_params file included with nginx
    include /usr/local/nginx/conf/fastcgi_params;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_index index.php;
    # Override the SCRIPT_FILENAME variable set by fastcgi_params
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    # Pass to upstream PHP-FPM; This must match whatever you name your upstream connection
    fastcgi_pass phpfpm;
    }

    }
  2. sgomez84 renamed this gist Jan 4, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. sgomez84 created this gist Jan 4, 2017.
    81 changes: 81 additions & 0 deletions nginx.cong
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,81 @@
    upstream phpfpm {
    #server unix:/var/run/php5-fpm.sock;
    #avoid sockets for nginx-fpm on Linux, they are good for BSD
    server 127.0.0.1:9000;
    }

    server {
    listen 8080;
    server_name sumhr.com;
    rewrite ^(.*) $scheme://www.sumhr.com$1 permanent;
    }

    server {
    listen 8080;

    charset utf-8;
    server_name www.sumhr.com;
    root /var/www/sumhr_wp;
    index index.php index.html index.htm;

    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    access_log /var/www/sumhrapp/logs/access.log;
    error_log /var/www/sumhrapp/logs/error.log warn;

    # Global restrictions configuration file.
    # Designed to be included in any server {} block.</p>
    location = /favicon.ico {
    log_not_found off;
    access_log off;
    }

    location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
    }

    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
    location ~ /\. {
    deny all;
    }

    # Deny access to any files with a .php extension in the uploads directory
    # Works in sub-directory installs and also in multisite network
    # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
    location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
    }

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

    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    # Directives to send expires headers and turn off 404 error logging.
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires 24h;
    log_not_found off;
    }

    location ~ \.php$ {
    try_files $uri =404;

    # Fix for server variables that behave differently under nginx/php-fpm than typically expected
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # Include the standard fastcgi_params file included with nginx
    include /usr/local/nginx/conf/fastcgi_params;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_index index.php;
    # Override the SCRIPT_FILENAME variable set by fastcgi_params
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    # Pass to upstream PHP-FPM; This must match whatever you name your upstream connection
    fastcgi_pass phpfpm;
    }

    }