Skip to content

Instantly share code, notes, and snippets.

@fideloper
Last active December 1, 2023 08:20
Show Gist options
  • Select an option

  • Save fideloper/9477321 to your computer and use it in GitHub Desktop.

Select an option

Save fideloper/9477321 to your computer and use it in GitHub Desktop.

Revisions

  1. fideloper revised this gist Dec 16, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion example.conf
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ server {
    charset utf-8;

    location / {
    try_files \$uri \$uri/;
    try_files $uri $uri/ =404;
    }

    # Don't log favicon.ico nor robots.txt attempts
  2. fideloper revised this gist Mar 11, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions example.conf
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,16 @@
    server {
    # Pass any subdomain to the "www" subdomain
    # Redirect any subdomain to the root domain
    # to be captured by next server block
    server_name *.example.com;
    return 301 $scheme://www.example.com$request_uri;
    return 301 $scheme://example.com$request_uri;
    }

    server {
    root /var/www;
    index index.html index.htm;

    # Make site accessible from http://example.com
    server_name www.example.com
    server_name example.com

    access_log /var/log/nginx/example.com-access.log;
    error_log /var/log/nginx/example.com-error.log error;
  3. fideloper created this gist Mar 11, 2014.
    34 changes: 34 additions & 0 deletions example.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    server {
    # Pass any subdomain to the "www" subdomain
    # to be captured by next server block
    server_name *.example.com;
    return 301 $scheme://www.example.com$request_uri;
    }

    server {
    root /var/www;
    index index.html index.htm;

    # Make site accessible from http://example.com
    server_name www.example.com

    access_log /var/log/nginx/example.com-access.log;
    error_log /var/log/nginx/example.com-error.log error;

    charset utf-8;

    location / {
    try_files \$uri \$uri/;
    }

    # Don't log favicon.ico nor robots.txt attempts
    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; }

    error_page 404 /error404.html

    # Deny .htaccess file access
    location ~ /\.ht {
    deny all;
    }
    }