Articles of apache 2.2

Apache2:尝试将子域映射到子目录

所以基本上我想有:sub.domain.com/ 什么 – > domain.com/asub / 什么 我对此有点新,有点困惑。 我做的第一件事就是configuration我的DNS设置,以便sub.domain.com使用CNAME访问domain.com(Alogging和IP会更好吗?) 接下来,我进入我的VirtualHost文件,并有: RewriteEngine on RewriteCond %{HTTP_HOST} www.(.+) [NC] RewriteRule ^/(.*) http://domain.com/$1 [R] RewriteCond %{HTTP_HOST} ^sub.domain.com RewriteRule ^/(.*) http://domain.com/asub/$1 [R] 所以第一个规则是为了处理www。 并确保被正确捕获,它的工作原理。 第二个规则是我为子域映射添加的东西,它似乎没有做任何事情

Googlebot无法访问我的网站网站站长工具回复无法访问的robots.txt

当我尝试获取我的网站作为网站pipe理员工具中的googlebot时,它返回无法访问的robots.txt,调查后我明白谷歌机器人可以看到我的服务器: tcpdump | grep google 它返回谷歌可以访问我的服务器IP aa.bb.cc.xx或aa.bb.cc.yy. 但access_log或error_log或其他apache日志中没有任何内容。 cat access_log | grep google or cat error_log | grep aa.bb.cc.xx 其他机器人(冰,…)可以访问Apache,但谷歌不能。 在我的robots.txt或其权限没有问题,因为你知道robots.txt是没有必要的,所以我删除它,但网站pipe理员工具返回“无法访问robots.txt”,不是404没有find! 有关服务器的信息 服务器操作系统:CentOS 6 Web服务器:Apache 2.x 防火墙:IPTables已停用 SELinux被禁用 在我的服务器上没有任何其他安全措施。 我该如何调查这个问题,还有什么其他的命令可以帮助我find问题吗?

有没有Apache 2.2和内容filter(也许mod_proxy)的错误?

我在RHEL 6(实际上是Scientific Linux 6.4)上运行Apache 2.2.15-29,我试图设置一个带有内容重写的反向代理,以便代理网页上的所有链接都被重写,以引用代理主机。 我遇到了一些重写内容的问题,我想知道这是一个错误,还是我做错了什么(如果适用的话,如何做到这一点)。 我将内部主机( internal.example.com/foo )上的子目录代理到外部主机( external.example.com )的根目录上。 我需要重写HTML,CSS和Javascript内容来修复所有的URL。 我还在外部主机上托pipe了一些本地内容,我不认为这是一个问题,但我在这里提到完整性。 我的httpd.conf看起来大致是这样的: <VirtualHost *:80> ServerName external.example.com ServerAlias example.com # Serve all local content directly, reverse-proxy all unknown URIs. RewriteEngine On RewriteRule ^(/(index.html?)?)?$ http://internal.example.com/foo/ [P] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -f [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d RewriteRule ^.*$ – [L] RewriteRule ^/~ – [L] RewriteRule ^(.*)$ http://internal.example.com$1 [P] […]

caching破坏和包含Nginx的文件

在Apache中,您可以使用以下命令来cachingcss和js文件,并使用Apache的Include mod将它们作为单个文件进行caching: <FilesMatch "\.combined\.js$"> Options +Includes AddOutputFilterByType INCLUDES application/javascript application/json SetOutputFilter INCLUDES </FilesMatch> <FilesMatch "\.combined\.css$"> Options +Includes AddOutputFilterByType INCLUDES text/css SetOutputFilter INCLUDES </FilesMatch> <IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L] </IfModule> 我知道这是可能的nginx,但我似乎无法得到正确的语法。 – 编辑 – 添加一些代码 我到目前为止唯一的一件事是: location ~* (.+)\.(?:\d+)\.(js|css)$ { ssi on; try_files $uri $1.$2; } 我正在寻找的是能够结合所有js和css文件到单个文件使用combined关键字与数字caching破坏: style.combined.100.css javascript.combined.100.js […]

用ssl在apacheconfiguration几个站点

我需要在Apache中确保两个不同的网站。 其中之一应该只是代理端口8069上运行的不同服务器。 现在一个(本来就包含在apache中的)运行SSL: <VirtualHost *:443> ServerName 192.168.1.20 SSLEngine on SSLCertificateFile /etc/ssl/erp/oeserver.crt SSLCertificateKeyFile /etc/ssl/erp/oeserver.key DocumentRoot /var/www/cloud ServerPath /cloud/ #CustomLog /var/www/logs/ssl-access_log combined #ErrorLog /var/www/logs/ssl-error_log </VirtualHost> 另一个没有运行,甚至没有注册。 当我尝试访问它时,我收到一个exception(ssl_error_rx_record_too_long): <VirtualHost *:443> ServerName 192.168.1.20 ServerPath /erp/ SSLEngine on SSLCertificateFile /etc/ssl/erp/oeserver.crt SSLCertificateKeyFile /etc/ssl/erp/oeserver.key ProxyRequests Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyVia On ProxyPass / http://127.0.0.1:8069/ ProxyPassReverse […]

通过向不知名的IP发送404来隐藏HTTPauthentication领域?

我有一个Apache(2.2)在example.com上提供web应用程序。 该web应用程序有一个可通过example.com/debug访问的debugging页面。 /debug当前受到HTTP基本身份validation的保护。 由于只有非常小的用户可以访问debugging页面,所以我想根据IP地址来隐藏它,并将404返回给不能从我们的VPN访问的客户端。 仅基于IP地址提供404服务非常简单,详见https://serverfault.com/a/13071 。 但是,一旦我添加authentication,用户看到一个401而不是一个404 。 基本上,我需要的是: if ($REMOTE_ADDR ~ 10.11.12.*): do_basic_auth (aka return 401) else: return 404 更新这个工程: <VirtualHost …> … SetEnvIf REMOTE_ADDR 10.128.0.* HAS_debug=1 SetEnvIf REMOTE_ADDR 10.128.1.* HAS_debug=1 SetEnvIf REMOTE_ADDR 10.128.2.* HAS_debug=1 RewriteEngine On RewriteCond %{ENV:HAS_debug} !=1 RewriteRule ^/debug($|/) – [R=404,L] <Location /debug> AuthType Basic AuthName "hidden-debug" AuthUserFile … Require valid-user […]

如何在不设置ServerName的情况下redirect/重写FQDN URL?

通常在企业内部网中,用户不需要提供FQDN就可以将URL指向主机名。 例: http://internalHost 代替 http://internalHost.example.com 我想redirect用户/重写URL,以便一切都将使用FQDN。 这里是catch:我不想显式地设置ServerName。 (这是为了部署在多个Intranet上的产品,所以我们不能提前知道ServerName的值)。 根据: http : //wiki.apache.org/httpd/CouldNotDetermineServerName Apache使用反向查找来确定默认的FQDN。 我如何使用/引用Apache正在使用的mod_rewrite或redirect的FQDN?

拒绝与其他主机名的HTTPS连接

我已经为我的网站安装了一个SSL证书,然而,5个不同的域都指向同一个主机,如果用户被导向https://(the other four)他们会得到一个很大的红色屏幕。 如果我只有一个虚拟主机似乎是全部,这是我不想要的。 我试图让另一个虚拟主机来抓住未经authentication的域名: NameVirtualHost *:443 <VirtualHost *:443> ServerName example2.com ServerAlias example3.com DocumentRoot /srv/deadwww/ # contains nothing of consequence </VirtualHost> <VirtualHost *:443> ServerName example.com SSLEngine on SSLCertificateFile /path/to/certs/example.com.crt … 但是Apache甚至不会启动,咆哮着: [error] Server should be SSL-aware but has no certificate configured 所以,如果我只有一个VirtualHost条目,那么它就会捕获所有的名字,并且大部分都会失败,如果我在那之前尝试捕获这些坏名字,我不能这样做,因为Apache不会让我。 我如何解决这个问题?

Apache反向代理将不同的源IP范围转发到不同的目标URL

这可能是一个存在的问题(或在网上的某个地方),但我找不到它。 我们希望将我们的用户基础从后端服务器的一个实现缓慢迁移到不同服务器上的新实现。 在后端服务器前面已经有了一个Apache2反向代理。 因此,我们想要将一些源IP范围/子网代理到新的服务器,而将所有其他服务器redirect到原始服务器。 然后添加到代理新服务器的IP范围,直到他们都做。 然后删除旧的服务器。 有人能给我一些指示,这是如何在Apache中完成?

如果我的VirtualHost中指定了DocumentRoot,是否需要指定一个<Directory>?

我使用了一个稍微默认的VirtualHost文件,我之前configuration了一个(之前我对这个东西是如何工作的有很多知识),而且我不确定我应该保留什么。 我不想仅仅尝试一些东西,因为设置一个虚拟机,所有这些东西都是麻烦的,而且当前的configuration是在生产环境中,所以反复试验并不是真正的select。 这里是文件,更改名称以保护无辜: <VirtualHost *:80> ServerAdmin [email protected] ServerName www.my.hostname ServerAlias my.hostname DocumentRoot /var/www/mysite <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/mysite> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible […]