Nginx不提供已更改文档根目录中的文件

时间:2017-03-08 14:27:09

标签: php nginx ubuntu-16.04 cloudflare roundcube

我的Nginx(版本1.11.9)安装似乎有问题。我在我的Ubuntu 16.04 LTS服务器上设置了LEMP堆栈,并且还在其上运行了邮件服务。我正在使用以下代理: - Postfix和Dovecot。现在设置LEMP的原因是为了使用Roundcube来促进webmail。我在已启用站点的已删除链接中设置了符号链接,并添加了名为roundcube的已添加站点配置文件。我遇到的问题是default_server文件根目录没有从该位置加载任何页面,它似乎只是从Nginx默认位置加载页面/ usr / share / nginx / html

我已将root指定为/ usr / share / nginx / roundcube但没有从该位置加载页面。我现在已经过了3个星期了,因为我看不出这个问题,我只是感到沮丧。我将列出我修改过的Nginx配置文件。

非常感谢任何帮助。

P.S我正在使用Cloudflare DNS

谢谢Rob

nginx.conf: -

user www-data;
worker_processes 2;
pid /run/nginx.pid;

events {
    worker_connections 1024;
    multi_accept on;
}

http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10 10;
types_hash_max_size 2048;
server_tokens off;
port_in_redirect off;
client_max_body_size 4096k;
client_body_timeout 10;
client_header_timeout 10;
send_timeout 10;
#server_names_hash_bucket_size 64;
#server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_min_length 1100;
gzip_vary on;
gzip_proxied any;
# gzip_comp_level 6;
gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/rss+xml text/javascript image/svg+xml application/x-font-ttf font/opentype application/ vnd.ms-fontobject;

##
# SSL Settings
##
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
#ssl_prefer_server_ciphers on;

# Sitewide SSL settings
ssl_session_cache shared:SSL:10m;
ssl_buffer_size 4k;

# Sitewide proxy settings
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;

##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

#mail {
#   # See sample authentication script at:
#   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#   # auth_http localhost/auth.php;
#   # pop3_capabilities "TOP" "USER";
#   # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#   server {
#   listen     localhost:110;
#   protocol   pop3;
#   proxy      on;
#   }
#
#   server {
#   listen     localhost:143;
#   protocol   imap;
#   proxy      on;
#   }
#}

站点可用的配置文件“roundcube”内容: -

    server {
    listen 80;
    server_name example.com;
    if ($http_cf_visitor ~ '{"scheme":"http"}') {
    return 301 https://example.com$request_uri;
 }
}

server {
    listen 80;
    server_name example.com;
    if ($http_cf_visitor ~ '{"scheme":"http"}') {
    return 301 https://$host$request_uri;
 }
}

# HTTPS server
server {
    listen 443 ssl http2 default_server;
    server_name example.com;
    root /usr/share/nginx/roundcube;
    index index.html index.php;
    autoindex off;

    ssl on;
    ssl_certificate /etc/ssl/private/ssl-chain-mail-example.com.pem;
    ssl_certificate_key /etc/ssl/private/ssl-key-decrypted-mail-example.com.key;
    ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
    ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES    :RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS;
    ssl_prefer_server_ciphers on;
    ssl_ecdh_curve secp521r1;

    # Client auth via certs
#   ssl_client_certificate /etc/ssl/private/example.com.crt;
#   ssl_trusted_certificate /etc/ssl/private/example.com.crt;
#   ssl_verify_client on;

    location / {
#       if ($ssl_client_s_dn !~* "user@example.com") {
#           return 301 http://www.jurassicsystems.com/;
#       }
#       error_page 403 @fallback;
    }

    location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
        deny all;
    }

    location ~ ^/(config|bin|SQL|logs|temp)/ {
        deny all;
    }

    location ~ ^/.*\.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass php7.1-fpm-sock;
        fastcgi_param HTTPS on;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
    }

    location @fallback {
        return 301 http://www.jurassicsystems.com/;
    }
}

0 个答案:

没有答案