AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 853348
Accepted
Isaac Palacio
Isaac Palacio
Asked: 2017-06-01 23:28:14 +0800 CST2017-06-01 23:28:14 +0800 CST 2017-06-01 23:28:14 +0800 CST

子域中的 Nginx:如果索引是 .html,如果下载索引是 .php,则错误 403 被禁止

  • 772

它只在子域中发生在我身上,其余的效果很好:

如果索引其扩展名是 htm 或 html 给出错误:

“403 禁止”

如果索引其扩展名是 php 尝试下载。

/ srv / www 中的权限对于所有子域都是相同的,并且它们有效。

我把配置conf:

server {
            ## Escucha en el puerto 80 (HTTP)
            listen 80;

            server_name musica.domain.com;

            location / {
                    return 301 https://$server_name$request_uri;
            }
}


server {
    ## Escucha en el puerto 443 (HTTPS)
    listen 443 ssl http2;

    server_name musica.domain.com;

    ## Certificados
    ssl_certificate /etc/letsencrypt/live/musica.domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/musica.domain.com/privkey.pem;
    include snippets/ssl-params.conf;

    access_log  /var/log/nginx/musica_access.log;
    error_log   /var/log/nginx/musica_error.log;

    root /srv/www/sonerezh;

    index index.html index.htm index.php;

    location ~ /.well-known {
            allow all;
    }

    location / {
#              try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/musica.sock;
            #fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_index index.php;
            include fastcgi_params;
    }
}

该nginx -T命令显示您实际上正在读取子域配置文件。

子域访问日志:

195.16.143.6 - - [01/Jun/2017:09:16:29 +0200] "GET /favicon.ico HTTP/1.1" 404 143 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"
195.16.143.6 - - [01/Jun/2017:09:17:26 +0200] "GET / HTTP/1.1" 200 90 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"
195.16.143.6 - - [01/Jun/2017:10:09:59 +0200] "GET / HTTP/1.1" 200 90 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"
195.16.143.6 - - [01/Jun/2017:10:10:37 +0200] "GET / HTTP/1.1" 403 143 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"

子域错误日志:

2017/06/01 09:16:29 [error] 3464#3464: *2295 open() "/srv/www/sonerezh/favicon.ico" failed (2: No such file or directory), client: 195.16.143.6, server: musica.domain.com, request: "GET /favicon.ico HTTP/1.1", host: "musica.domain.com"
2017/06/01 09:16:29 [error] 3464#3464: *2295 open() "/srv/www/sonerezh/favicon.ico" failed (2: No such file or directory), client: 195.16.143.6, server: musica.domain.com, request: "GET /favicon.ico HTTP/1.1", host: "musica.domain.com"
2017/06/01 10:10:37 [error] 3466#3466: *2350 directory index of "/srv/www/sonerezh/" is forbidden, client: 195.16.143.6, server: musica.domain.com, request: "GET / HTTP/1.1", host: "musica.domain.com"

nginx.conf:

user bichomen bichomen;

worker_processes auto;
worker_rlimit_nofile 2048;
#pcre_jit on;

pid /var/run/nginx.pid;

#                        [ debug | info | notice | warn | error | crit ]

error_log  /var/log/nginx.error_log  info;

events {
    worker_connections   2000;

    # use [ kqueue | epoll | /dev/poll | select | poll ];
    # use poll;
}


http {
    include mime.types;
    default_type application/octet-stream;


    log_format main      '$remote_addr - $remote_user [$time_local] '
                         '"$request" $status $bytes_sent '
                         '"$http_referer" "$http_user_agent" '
                         '"$gzip_ratio"';

    log_format download  '$remote_addr - $remote_user [$time_local] '
                         '"$request" $status $bytes_sent '
                         '"$http_referer" "$http_user_agent" '
                         '"$http_range" "$sent_http_content_range"';

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

    client_header_buffer_size    1k;
    large_client_header_buffers  4 4k;

    gzip on;
    gzip_min_length  1100;
    gzip_buffers     4 8k;
    gzip_types       text/plain;

    output_buffers   1 32k;
    postpone_output  1460;

    sendfile         on;
    tcp_nopush       on;
    tcp_nodelay      on;
    send_lowat       12000;

    keepalive_timeout  75 20;

    #lingering_time     30;
    #lingering_timeout  10;
    #reset_timedout_connection  on;

    include sites-enabled/*.conf;
}

权限:

$ ls -l /srv/www/
drwxr-x--x  4 bichomen bichomen 4096 Jun  1 10:10 sonerezh

$ ls -l /srv/www/sonerezh/
-rw-rw-r-- 1 bichomen bichomen  90 Jun  1 09:15 index.html

使用 index.html

使用 index.php

nginx
  • 1 1 个回答
  • 2498 Views

1 个回答

  • Voted
  1. Best Answer
    Isaac Palacio
    2017-06-08T22:55:22+08:002017-06-08T22:55:22+08:00

    已经解决了安装nginx的所有问题:

    https://github.com/Sonerezh/sonerezh/issues/305

    • 0

相关问题

  • Gzip 与反向代理缓存

  • nginx 作为代理的行为

  • Nginx 学习资源 [关闭]

  • 提供 70,000 个静态文件 (jpg) 的最佳方式?

  • 在 Apache、LightTPD 和 Nginx Web 服务器上提供 PHP 5.x 应用程序的现状?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve