标签: apache2

警告:DocumentRoot 不存在...但它确实存在

我正在尝试在 Ubuntu 20.04 中使用 Apache 托管 3 个站点,但是当我尝试连接到它们时,我得到

未找到。在此服务器上找不到请求的 URL。

这是我的虚拟主机文件

<VirtualHost *:80>
        ServerName nico1.com
        Redirect permanent / https://nico1.com
</VirtualHost>

<VirtualHost *:443>
        ServerName nico1.com
        DocumentRoot /var/www/index1.html
        <Directory /var/www/index1.html>
                AllowOverride All
        </Directory>

        SSLEngine on
        SSLCertificateFile /etc/ssl/private/nico1.crt
        SSLCertificateKeyFile /etc/ssl/private/nico1.key
</VirtualHost>

<VirtualHost *:80>
        ServerName nico2.com
        Redirect permanent / https://nico2.com
</VirtualHost>

<VirtualHost *:443>
        ServerName nico2.com
        DocumentRoot /var/www/index2.html
        <Directory /var/www/>
                AllowOverride All
        </Directory>

        SSLEngine on
        SSLCertificateFile /etc/ssl/private/nico2.crt
        SSLCertificateKeyFile /etc/ssl/private/nico2.key
</VirtualHost>

<VirtualHost *:80>
        ServerName nico3.com
        Redirect permanent / https://nico3.com
</VirtualHost>

<VirtualHost *:443>
        ServerName nico3.com
        DocumentRoot /var/www/index3.html …
Run Code Online (Sandbox Code Playgroud)

apache2

5
推荐指数
1
解决办法
787
查看次数

apache 多视图,如何禁用它

我有一个 OS X Snow Leropard 服务器正在运行,我想从 Apache 禁用 multivewis。我可以添加Options -MultiViews到我拥有的每个 .htacces 文件中,但我想必须有一个全局选项。禁用mod_negotiation.so会使所有页面无用,所以这不是我正在寻找的选项..

谢谢您的帮助!

.htaccess httpd.conf apache-2.2 apache2

4
推荐指数
1
解决办法
2万
查看次数

带有包含空格的 URL 的 Apache RewriteMap 不起作用

我实际上是RewriteMap在我的 vhost 中使用一个指令来重定向 800 个 URL 的列表。它安静地工作:

RewriteEngine On
RewriteMap redirects dbm=db:/data/apps/project/current/configuration/etc/httpd/conf/redirects.db
RewriteCond ${redirects:$1} !=""
RewriteRule ^(.*)$ ${redirects:$1} [redirect=permanent,last]
Run Code Online (Sandbox Code Playgroud)

我使用redirect.txt包含映射的文件。然后将其转换为db文件:

httxt2dbm -f db -i /data/apps/project/current/configuration/etc/httpd/conf/redirects.txt -o /data/apps/project/current/configuration/etc/httpd/conf/redirects.db
Run Code Online (Sandbox Code Playgroud)

例如对于这种网址,就可以了:

/associations/old_index.php /
Run Code Online (Sandbox Code Playgroud)

但是当 URL 包含空格时它不起作用:(我想它与其他特殊字符相同)

/Universités%20direct   /
Run Code Online (Sandbox Code Playgroud)

这个案子怎么处理?

mod-rewrite redirect virtualhost apache2

4
推荐指数
1
解决办法
3348
查看次数

意外删除/tmp/systemd-private-015eb2a30-apache2.service-9h6i

我不小心systemd-private-015eb2e9f67b4eef862c68e99fe0ba30-apache2.service-9h6i08从我的 /tmp 文件夹中删除了:

sudo rm -R /tmp/systemd-private-015eb2e9f67b4eef862c68e99fe0ba30-apache2.service-9h6i08

并不意味着它不会永久消失。我确信它会再次显示回来。这使我的代码中断,因为它没有找到将文件写入其中的安全文件夹。

我如何再次返回文件?

我尝试再次创建目录 - 只有 root 权限和所有权 - 但这不起作用。

systempath tmp systemd apache2

4
推荐指数
1
解决办法
3249
查看次数

apache2.conf 和 ProxyPass 中 keepalive 的区别

我在用 Apache 2.2.22

中的 Keepalive 指令之间有什么区别(如果有) /etc/apache2/apache2.conf

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On
Run Code Online (Sandbox Code Playgroud)

以及/sites-enabled使用 ProxyPass 时配置中的指令

 ProxyPass / http://localhost:8080/app/ connectiontimeout=28800 timeout=28800 Keepalive=On
Run Code Online (Sandbox Code Playgroud)

proxy keepalive 502-error apache2

4
推荐指数
1
解决办法
9490
查看次数

当服务已经启动时“systemctl start service”

我,systemctl start apache2在服务已经启动的情况下运行(或其他服务)时会发生什么?

apache2服务一天启动几百次会不会有问题?(防止服务关闭)或者它会使用内存还是危险?

debian start systemctl apache2

4
推荐指数
1
解决办法
1290
查看次数

为什么 $_SERVER['HTTP_HOST'] 有时是 example.com,有时是 example.com:443?

这是一个在 Apache 上运行 PHP 7 的 Ubuntu 服务器,带有一个强制执行 TLS(使用标准端口)的网站。据我了解,https://example.comhttps://example.com:443是完全等价的(事实上,在我的浏览器中,当我输入端口号时,端口号会从地址栏中消失)。然而HTTP_HOST 通常只包含域名,但有时也包含端口号。这可能适用于机器人访问者(我还没有分析日志),但即便如此,我也不知道如何做到。有什么实际区别吗?

(这会导致一些问题,因为我们的一些日志和工作队列以及服务器端缓存是由 分隔开的HTTP_HOST,因此在不同主机上拥有相同的站点报告会令人困惑。)

php apache2

4
推荐指数
1
解决办法
1万
查看次数

有没有办法共享或重用 Apache 配置

我的 Apache 服务器上有以下目录结构

/var/www/domain.com/
    index.html
    site-1/
    site-2/
    .
    .
    .
    site-N/
Run Code Online (Sandbox Code Playgroud)

每个站点都使用以下配置文件,其中变量“port”、“site”和“hub”是唯一更改的值

<IfModule mod_ssl.c>
    <VirtualHost *:443>
        # DOMAIN CONFIGURATION
        Define domain domain.dev

        ServerName ${domain}
        ServerAlias www.${domain}
        DocumentRoot /var/www/${domain}

        <Directory "/var/www/${domain}">
            AuthType Basic
            AuthName "${domain} Authentication"
            AuthUserFile /etc/apache2/.htpasswd
            Require valid-user
            <Files "manifest.json">
                Require all granted
            </Files>
        </Directory>

        SSLEngine on
        RewriteEngine on
        SSLProxyEngine on
        SSLProxyVerify none
        SSLProxyCheckPeerCN off
        SSLProxyCheckPeerName off
        SSLProxyCheckPeerExpire off

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        SSLCertificateFile /etc/letsencrypt/live/${domain}/cert.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/${domain}/privkey.pem
        SSLCertificateChainFile /etc/letsencrypt/live/${domain}/fullchain.pem

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
        </FilesMatch>

        <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars …
Run Code Online (Sandbox Code Playgroud)

apache2

4
推荐指数
1
解决办法
594
查看次数

带有 mod_http2 的 Apache 是否容易受到 Http/2 快速重置 CVE-2023-44487 的影响

我在 apache 网站上找不到任何有关此内容的信息,因此我禁用了 http/2 作为预防措施。有关如何保护 Apache2 免受此影响的任何信息吗?

apache2

4
推荐指数
1
解决办法
3449
查看次数

Apache:返回位置的静态字符串

对于.well-known路径,我想返回一个静态 JSON 文件/字符串。

使用 nginx,这似乎是可能的,而无需通过在配置文件中指定内容来创建该文件:

location /.well-known/foo {
    return 200 '{"foo": "bar"}';
    default_type application/json;
    add_header Access-Control-Allow-Origin *;
}
Run Code Online (Sandbox Code Playgroud)

apache 有类似的可能吗?这是我到目前为止:

<Location "/.well-known/foo">
        # return '{"foo": "bar"}'
        ForceType application/json
        Header set Access-Control-Allow-Origin *
</Location>
Run Code Online (Sandbox Code Playgroud)

mod-rewrite web-server apache-2.4 apache2

3
推荐指数
2
解决办法
668
查看次数