Welcome Guest, Not a member yet? Register   Sign In
Tutorial problem with NGINX...?
#4

This works for me in Nginx. Maybe you can find a hint here.

httpd.conf
Code:
user nobody;
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
   worker_connections  1024;
}


http {
    server_names_hash_bucket_size 128;
    server_names_hash_max_size 1024;
    
    ssl_session_cache   shared:SSL:10m;
   ssl_session_timeout 10m;
    
   include       mime.types;
   default_type  application/octet-stream;
    index index.php index.html index.htm;

   #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
   #                  '$status $body_bytes_sent "$http_referer" '
   #                  '"$http_user_agent" "$http_x_forwarded_for"';

   access_log off;
    
    server_tokens off;

    # copies data between one FD and other from within the kernel
    # faster then read() + write()
    sendfile on;

    # send headers in one peace, its better then sending them one by one
    #tcp_nopush on;

    # don't buffer data sent, good for small data bursts in real time
    #tcp_nodelay on;
    
    client_body_timeout 10s;
    client_header_timeout 10s;
    keepalive_timeout 10s 10s;
    send_timeout 15s;
    
    client_max_body_size 8M;

    # Gzip Settings
   gzip  on;
    gzip_disable "msie6";
    
    gzip_vary on;
    gzip_comp_level 6;
    gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon image/webp application/json application/vnd.ms-access application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint application/x-shockwave-flash image/tiff application/x-font-ttf audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel;
    
    etag off;
    
   server {
       listen       80;
       server_name  _;
        
        include restrictions.conf;

       location / {
           root   /var/www/sites/emptyDomain;
           index  index.html index.htm;
       }
   }
    
    include /usr/local/nginx/conf/sites-enabled/*.conf;
}


conf/sites-available/localhost.conf
Code:
server {
   listen 80;
   server_name localhost;
    root /var/www/sites/localhost/www;
    #access_log off;
    
    include restrictions.conf;
    include general.conf;
    
    access_log /var/www/logs/localhost_access.log combined;
    error_log /var/www/logs/localhost_error.log;
    
    location / {
        include security.conf;
        # This is cool because no php is touched for static content.
        # include the "?$args" part so non-default permalinks doesn't break when using query string
        try_files $uri $uri/ /index.php?$args;
    }
    
    location ~ \.php$ {
        #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        fastcgi_param HTTP_PROXY "";
        fastcgi_pass unix:/var/run/php-fpm/www.socket;
        include fastcgi.conf;
    }

   error_page  500 502 503 504  /50x.html;
   location = /50x.html {
       root  /usr/share/nginx/html;
   }
}
restrictions.conf
Code:
# Global restrictions configuration file.
# Designed to be included in any server {} block.
location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /apple-touch-icon.png {
    log_not_found off;
    access_log off;
}

location = /apple-touch-icon-precomposed.png {
    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;
}
general.conf
Code:
location ~* .(jpg|jpeg|gif|css|png|js|ico|txt|woff|otf|ttf|eot|svg)$ {
    access_log off;
    log_not_found off;
    expires 30d;
   add_header Pragma public;
   add_header Cache-Control "public";
   add_header Vary "Accept-Encoding";
}
security.conf
Code:
## Only allow these request methods ##
    if ($request_method !~ ^(GET|HEAD|POST)$ ) {
        return 444;
    }
## Do not accept DELETE, SEARCH and other methods ##
fastcgi.conf
Code:
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REQUEST_SCHEME     $scheme;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;
Reply


Messages In This Thread
Tutorial problem with NGINX...? - by ryan_f - 04-03-2018, 01:24 PM
RE: Tutorial problem with NGINX...? - by ryan_f - 04-03-2018, 03:59 PM
RE: Tutorial problem with NGINX...? - by InsiteFX - 04-04-2018, 02:41 AM
RE: Tutorial problem with NGINX...? - by jreklund - 04-04-2018, 04:51 AM
RE: Tutorial problem with NGINX...? - by ryan_f - 04-04-2018, 08:16 AM
RE: Tutorial problem with NGINX...? - by InsiteFX - 04-04-2018, 02:06 PM
RE: Tutorial problem with NGINX...? - by ryan_f - 04-05-2018, 09:37 AM
RE: Tutorial problem with NGINX...? - by jreklund - 04-05-2018, 10:36 AM
RE: Tutorial problem with NGINX...? - by ryan_f - 04-05-2018, 11:51 AM
RE: Tutorial problem with NGINX...? - by jreklund - 04-05-2018, 01:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB