Articles of apache 2.4

Apache中具有不同后端端口的dynamic虚拟主机

我正在为应用程序创build一系列子域,每个子域都通过mod_proxy获取自己的后端服务器。 我想避免每次发生这种情况都要生成一个新的虚拟主机,而是依靠命名机制(子域是基于数字的)。 假设域名为promotion-4321.example.com ,后端服务器将在端口4321上侦听 我可以创build一个从主机名提取4321 (并捕获所有promotion-XXXX.example.com )的apacheconfiguration,并使用它来将请求引导到端口4321上的后端?

当mpm是事件时,需要php-zts扩展吗?

我的PHP是正确安装和工作,但在Apache启动时,我有所有当前加载的扩展与警告消息,如… [23-Dec-2015 21:47:45 UTC] PHP Warning: PHP Startup: bz2: Unable to initialize module Module compiled with build ID=API20131226,NTS PHP compiled with build ID=API20131226,TS These options need to match in Unknown on line 0 [23-Dec-2015 21:47:45 UTC] PHP Warning: PHP Startup: calendar: Unable to initialize module Module compiled with build ID=API20131226,NTS PHP compiled with build ID=API20131226,TS […]

不存在的ssl子域优美的404处理?

运行Apache / 2.4.16(Ubuntu)。 我有5个子域(app,cdn,api,m,www / home)的证书。 我想要未定义的子域名为404.我想https://domain.com/404将是适当的地方。 我如何做到这一点,并避免“你的连接不是私人的”警告? 这是处理这个问题的正确方法吗? 我的configuration文件看起来像这样(简化): #APP <VirtualHost _default_:443> ServerName app.domain.com DocumentRoot /var/www/html/app </VirtualHost> #CDN <VirtualHost _default_:443> ServerName cdn.domain.com DocumentRoot /var/www/html/cdn </VirtualHost> #API <VirtualHost _default_:443> ServerName api.domain.com DocumentRoot /var/www/html/api </VirtualHost> #M <VirtualHost _default_:443> ServerName m.domain.com DocumentRoot /var/www/html/m </VirtualHost> #HOME <VirtualHost _default_:443> ServerName domain.com ServerAlias www.domain.com DocumentRoot /var/www/html/home </VirtualHost>

Apache虚拟主机..redirect.. ProxyPass ..和别名

我已经尝试了一切,并寻求帮助下面…我们正在做一个Proxypass的redirect,但是我想创build一个别名,并指出每个人在那里而不是Proxypass。 目前,当你去server.org时,它会redirect到 – > server.org/test/,它被代理 – > localhost:8080 / test / 我想创build一个别名/ mm,以便server.org/mm/或server.org/test/mm/将被redirect到提供的别名。 这可能吗? 我试过(ProxyPass / mm!)没有运气 提前致谢! DocumentRoot "/var/www/html" Redirect "/" "https://server.org/test/" Alias /mm "/var/opt/mm" <Directory "/var/opt/mm"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass /test/ http://localhost:8080/test/ ProxyPreserveHost On ProxyStatus […]

如何在apacheconfiguration中testing条件?

我想在apache中testing一个configuration。 我怎样才能“debugging”configuration文件? 例如,假设我有: <IfModule mod_geoip.c> GeoIPEnable On GeoIPDBFile PATH_TO_LIB\GeoIP.dat GeoIPEnableUTF8 On GeoIPOutput All </IfModule> 我可以在本地发送伪造的IP到头部吗? (即)我可以在本地伪造/剥离另一个IP比127.0.0.1?

Apache Web服务器中基于端口的反向代理

我有两个Web应用程序http:// app1:8080和http:// app2:3000在两个不同的端口和不同的机器上运行。 我必须通过Apache Web服务器http:// myapp传递应用程序stream量。 现在,我们可以通过将应用程序挂载到特定的位置来将apache web服务器configuration为反向代理。 例如, ProxyPass /app1/ http://app1:8080/ ProxyPass /app2/ http://app2:3000/ ProxyPassReverse /app1/ http://app1:8080/ ProxyPassReverse /app2/ http://app2:3000/ 在映射之后, http:// myapp / app1指向http:// app1:8080 , http:// myapp / app2指向http:// app2:3000 。 但是,我的要求是http:// myapp:8080应指向http:// app1:8080和http:// myapp:3000应该指向http:// app2:3000 。 请指导我如何在Apache Web服务器端口的基础上反向代理stream量。

如果用户使用IP而不是(子)域,则redirect

我有一个Apache服务器,我想redirect每个连接到我的网站的用户,如果他们不使用特定的域,在这种情况下,一个子域。 所以,如果我使用IP我想要redirect到其他地方,如果我使用特定的域我想获得访问我的网站。 我已经find了VirtualHost但是我所有的search引擎都没有帮助。 我必须在sites-available创build新文件吗? 所以我创build了该文件并将其命名为redirect。 如果我打开我的网站现在我redirect,但它应该显示我正确的网站。 我错了什么? 这里是我的文件的内容: 000-default.conf <VirtualHost *:80> #ServerName www.example.com ServerAdmin webmaster@localhost Redirect 301 / http://www.example.com/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> redirect.conf <VirtualHost *:80> ServerName http://www.examplesubdomain.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>

将端口443redirect到防火墙的端口80?

我最近遇到了一个情况,我运行的Web服务器不能再提供HTTPSstream量(由于一些SSL证书问题)。 由于服务器无法处理此stream量,因此我无法使用Apacheredirect规则redirect到非https。 然后我尝试在防火墙/ NAT设备上将XXXX:443redirect到XXXX:80,但似乎无法使其工作。 我不问如何做到这一点,因为它是特定于我的基础设施和设备。 但是有没有可能做到这一点? 一位同事build议,由于客户端正在请求安全连接,因此我们可能无法做到这一点,因为我们正在以不安全的连接进行响应。 这将不同于用302响应,并强制客户端使用apacheredirect对非https进行新的请求。

在不使用mod_rewrite的情况下,将所有子域redirect到https的最佳方法是什么?

我目前正在使用mod_rewriteredirect到https的所有子域名,但多个来源已经build议 使用mod_rewrite来做这不是推荐的行为。 请参阅RedirectSSL apache文档build议redirect和RedirectMatch: RewriteRule的一个常见用途是redirect整个类的URL。 例如,/ one目录中的所有URL都必须redirect到http://one.example.com/ ,或者所有http请求都必须redirect到https。 这些情况最好通过Redirect指令处理。 请记住,redirect保留了path信息。 也就是说,redirect一个URL /一个也会redirect所有的URL,比如/one/two.html和/one/three/four.html。 不幸的是,这些文档(以及其他所有我发现的)都只考虑匹配一个域,而不是所有的子域。 RedirectMatch似乎是这样一个相对简单的任务的好候选人,但我似乎无法得到“http”匹配,如我所料: RedirectMatch permanent "^http://(.*)$" "https://$1" 我的猜测,为什么这是行不通的,因为redirectMatch正在寻找一个path,而不是一个URI,但在这一点上,我卡住了。 是否有可能完成所有子域的redirect到https没有mod_rewrite,或者是最好的方法?

我可以使用Apache来反向代理基于子目录而不是子域?

我现在所拥有的是几个由子域标识的虚拟主机,然后像这样代理服务器: <VirtualHost *:80> ProxyPass / http://192.168.1.1/ ProxyPassReverse / http://192.168.1.1/ ServerName sub1.example.com </VirtualHost> <VirtualHost *:80> ProxyPass / http://192.168.1.2/ ProxyPassReverse / http://192.168.1.2/ ServerName sub2.example.com </VirtualHost> 我想要的是Apache基于example.com/sub1,example.com/sub2等进行代理。 没有什么我已经尝试过似乎和子域一样工作。 我尝试过使用Alias指令,位置块等,但它不断重写URL到我的浏览器,当然不能到达后端机器。 这怎么能正确地做到?