diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf new file mode 100644 index 0000000..8bbc03c --- /dev/null +++ b/nginx/conf.d/default.conf @@ -0,0 +1,127 @@ +server { + # address and port accepted by the server + listen 80 default_server; + listen [::]:80 default ipv6only=on; + + # server IP to compare against http requests, uncomment and set proper value. + # Enter the hostname or IP address you use to reach this server. If you run on your dev environment it might be localhost. + # Note: If your vb install is in a folder inside your domain /forum/install/path please change location directives defined below to include the path first. e.G: + # vbulletin.com/forum + # + # css directive would be: + # location = /forum/css\.php { + # rewrite ^ /forum/core/css.php break; + #} + server_name localhost; + + # document root for request, uncomment and set proper value + # this should reflect the path that your vBulletin is installed in. + # This is usually /var/www/public_html/forumpath + root /var/www/html; + + index index.php index.html index.htm; + + try_files $uri $uri/ /index.php?$args; + + # log files, uncomment and set proper values + access_log /var/log/nginx/access-vb.log; + error_log /var/log/nginx/error-vb.log; + + real_ip_header X-Forwarded-For; + set_real_ip_from 172.17.0.0/16; + + # configuration rules + # legacy css being handled separate for performance + location = /css\.php { + rewrite ^ /core/css.php break; + } + + # make install available from presentation + location ^~ /install { + rewrite ^/install/ /core/install/ break; + } + + # any request to not existing item gets redirected through routestring + location / { + if (!-f $request_filename) { + rewrite ^/(.*)$ /index.php?routestring=$1 last; + } + } + + # make admincp available from presentation + location ^~ /admincp { + if (!-f $request_filename) { + rewrite ^/admincp/(.*)$ /index.php?routestring=admincp/$1 last; + } + } + + location ~* /(images|media|logs|tmp|js|css)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ { + return 403; + } + + location ~* /\.(ht|git|svn) { + deny all; + } + + ### Fix security issue when cgi.fixpathinfo = 1 + location ~ \..*/.*\.php$ { + return 403; + } + + ### + # PHP Configuration + ### + + # process any php scripts, not found gets redirected through routestring + location ~ \.php$ { + # handles legacy scripts + if (!-f $request_filename) { + rewrite ^/(.*)$ /index.php?routestring=$1 break; + } + + fastcgi_split_path_info ^(.+\.php)(.*)$; + fastcgi_pass php-upstream; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + #fastcgi_param SCRIPT_FILENAME $request_filename + + 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_intercept_errors on; + fastcgi_ignore_client_abort off; + fastcgi_connect_timeout 60; + fastcgi_send_timeout 180; + fastcgi_read_timeout 180; + fastcgi_buffers 256 16k; + fastcgi_buffer_size 32k; + fastcgi_temp_file_write_size 256k; + } + + ### + # Caching settings + ### + + location ~* ^.+\.(jpg|jpeg|gif|png|ico|pdf|swf)$ { + access_log off; + expires 1h; + log_not_found off; + } + + location ~* ^.+\.(css|js)$ { + access_log off; + expires 1h; + } +} + +upstream php-upstream { + # address to accept FastCGI requests. Make sure you set the right value under your fast cgi conf. + # e.g.- Ubuntu 12.10 using php5-fpm Ubuntu /etc/php5/fpm/pool.d/www.conf +# server unix:/var/run/php8.3-fpm.sock; + server php83:9000; +}