Welcome! Log In Create A New Profile

Advanced

Pages downloaded instead of displayed

Posted by Sil68 
Pages downloaded instead of displayed
August 17, 2012 07:52AM
I'm observing some kind of a weird phenomenon: any page but the ones located directly in the document root, and page other than a html one, is getting downloaded instead of (interpreted and) displayed.

Eg. /index.html works perfectly fine, /subdir/index.html gets downloaded.

I've split the nginx configuration into several, smaller files (see below).

nginx.conf
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
user www www;
worker_processes 1;
worker_rlimit_nofile 8192;

error_log /opt/local/var/log/nginx/error.log;
pid /opt/local/var/run/nginx/nginx.pid;

events {
multi_accept on;
worker_connections 1000;
}


http {

include conf.d/mime.types;
default_type application/octet-stream;

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 /opt/local/var/log/nginx/access.log;

client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;

client_header_buffer_size 1k;
large_client_header_buffers 4 4k;

server_tokens off;

sendfile on;
#tcp_nopush on;
tcp_nodelay on;

#keepalive_timeout 0;
keepalive_timeout 65;

gzip on;
gzip_comp_level 2;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

upstream backend_php {
ip_hash;
server unix:/opt/local/var/run/php/php-fpm.sock;
}

index index.html index.htm index.php index.php3 index.php4 index.php5;

include sites-enabled/*;

}
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


sites-enabled/localhost
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
server {

### general server settings
listen 80;
#listen 443;
server_name localhost;

### ssl settings
#ssl_certificate /opt/local/etc/openssl/ssl.crt/localhost.crt;
#ssl_certificate_key /opt/local/etc/openssl/ssl.key/localhost.key;

### logfile settings
access_log /opt/local/var/log/nginx/localhost-access.log;
error_log /opt/local/var/log/nginx/localhost-error.log debug;
rewrite_log on;

### document root
root /opt/local/var/nginx/html;

### redirect server error pages to the static pages
include conf.d/error.conf;

### configure FastCGI
include conf.d/fastcgi.conf;
include conf.d/fastcgi_php.conf;

### configure access to PHP-FPM's status and ping
include conf.d/php-fpm.conf;

### various application-specific settings
# include conf.d/drupal.conf;
# include conf.d/phplist.conf;
# include conf.d/piwik.conf;
include conf.d/tools.conf;

### default root location
location / {
try_files $uri $uri/ @rewrites;
}

### rewrite uri
location @rewrites {
rewrite ^ /index.php last;
}

### catch static file requests, such as images, css, js, etc.
include conf.d/static.conf;

### don't log any of the locations or report any error
include conf.d/drop.conf;

}
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


error.conf
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;

location = /(404|50x).html {
root /opt/local/var/nginx/html;
}
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


fastcgi.conf
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
# workaround as fastcgi_param cannot be used inside if statements
#set $https "";
#if ($scheme = https) {
# set $https on;
#}

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 SCRIPT_FILENAME $document_root$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 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;

#fastcgi_read_timeout 6000;
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


fastcgi_php.conf
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
location ~ \.(php|php3|php4|php5)$ {

# Filter out arbitrary code execution
location ~ \..*/.*\.(php|php3|php4|php5)$ {
return 404;
}
try_files $uri $uri/ /404.html;

keepalive_requests 0;

fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_index index.php;
fastcgi_param REDIRECT_STATUS 200;

fastcgi_pass backend_php;
}
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


php-fpm.conf
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
location ~ ^/(status|ping)$ {

### configure FastCGI
include conf.d/fastcgi.conf;
fastcgi_pass backend_php;

### configure access
allow 10.0.0.0/8;
allow 127.0.0.0/24;
allow 192.168.0.0/16;
deny all;
}
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


tools.conf
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
location ^~ /tools {
root /Volumes/MHData/Web;
autoindex on;
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


static.conf
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
#expires 7d;

add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";

log_not_found off;
}
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


drop.conf
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
# remove the robots line if you want to use wordpress' virtual robots.txt
location = /robots.txt {
access_log off;
log_not_found off;
}

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

location ~ /\. {
access_log off;
log_not_found off;
deny all;
}

location ~ ~$ {
access_log off;
log_not_found off;
deny all;
}

# deny access to .htaccess files, if Apache's document root concurs with nginx's one
location ~ /\.ht {
deny all;
}

# very rarely should these ever be accessed outside of your lan
location ~* \.(txt|log)$ {
allow 10.0.0.0/8;
allow 127.0.0.0/24;
allow 192.168.0.0/16;
deny all;
}
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 277
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready