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 / 问题 / 1066714
Accepted
Tom
Tom
Asked: 2021-06-15 14:52:21 +0800 CST2021-06-15 14:52:21 +0800 CST 2021-06-15 14:52:21 +0800 CST

HTTP 方法阻止在子域上不起作用

  • 772

我在 apache.conf 中执行了除 GET、POST 和 OPTIONS 之外的方法的阻塞,当我尝试通过 IP 运行服务器时阻塞工作。

但是在子域上配置相同的阻止(通过可用的站点)时,不会发生这种阻止。我做错了什么?

apache2.conf

<Directory /var/www/>
    Options None
    AllowOverride None
    Require all granted

    <LimitExcept GET POST OPTIONS>
        Require all denied
    </LimitExcept>
</Directory>

站点可用/子域.example.com.conf

<VirtualHost *:80>
    ServerName subdomain.example.com
    ServerAlias subdomain.example.com
    DocumentRoot /var/www/html/subdomain.example.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Header append X-FRAME-OPTIONS "SAMEORIGIN"

    RewriteCond %{REQUEST_URI} !^/\.well\-known/acme\-challenge/
    RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>

<VirtualHost *:443>
    SSLEngine on

    SSLCertificateFile      /certs/example.crt
    SSLCertificateKeyFile   /certs/example.key
    SSLCertificateChainFile /certs/example-intermediary.crt

    Protocols h2 http/1.1

    Header always set Strict-Transport-Security "max-age=31536000"

    Header append X-FRAME-OPTIONS "SAMEORIGIN"

    <Directory /var/www/html/subdomain.example.com>
        Options None
        AllowOverride None
        Require all granted

        <LimitExcept GET POST OPTIONS>
            Require all denied
        </LimitExcept>
    </Directory>

    ServerName subdomain.example.com
    ServerAlias subdomain.example.com
    DocumentRoot /var/www/html/subdomain.example.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

这个锁不起作用,因为在执行带有 PUT、DELETE、LOCK 等的请求时,页面内容正常返回。

apache-2.4
  • 1 1 个回答
  • 78 Views

1 个回答

  • Voted
  1. Best Answer
    ezra-s
    2021-06-15T22:36:31+08:002021-06-15T22:36:31+08:00

    您应该停止使用那种复杂的旧方法来限制方法。

    加载 mod_allowmehtods.so 并以更简单的方式定义您想要允许的内容。

    LoadModule allowmethods_module modules/mod_allowmethods.so
        
    <Directory /var/www> 
    #other directives
    AllowMethods GET POST OPTIONS 
    </Directory>
    

    除非您在子目录中用其他东西覆盖它,否则这将在服务器范围内工作。尝试让我们知道。

    • 2

相关问题

  • Apache2 - SSL 不工作

  • Apache <VirtualHost> 标签,如果客户端的 IP = x 则不重定向... 怎么做?

  • 我无法启用我的网站?[关闭]

  • SELinux 阻止 Apache 写入文件

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