在Apache中向反向代理添加异常

时间:2018-01-23 08:31:18

标签: apache reverse-proxy

我在ubuntu 16.04服务器上配置了一个应用程序(jitsi-meet),通过Apache提供服务。应用程序的DocumentRoot位于/ usr / share / jitsi-meet,Apache配置已通过脚本自动安装应用程序。服务器有一个FQDN,应用程序可以通过基本网址直接使用,比如http://example.com。我还通过letsencrypt安装了SSL证书,该证书还负责http到https重定向。

/etc/apache2/sites-available/example.com.conf上可用的当前Apache配置looks like this.

<VirtualHost *:80>
ServerName example.com
Redirect permanent / https://example.com/
   RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:443>

  ServerName example.com

  SSLProtocol TLSv1 TLSv1.1 TLSv1.2
  SSLEngine on
  SSLProxyEngine on
  SSLCipherSuite "EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA256:EECDH$
  SSLHonorCipherOrder on
  Header set Strict-Transport-Security "max-age=31536000"

  DocumentRoot "/usr/share/jitsi-meet"
  <Directory "/usr/share/jitsi-meet">
    Options Indexes MultiViews Includes FollowSymLinks
    AddOutputFilter Includes html
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>

      ErrorDocument 404 /static/404.html

Alias "/config.js" "/etc/jitsi/meet/example.com-config.js"
  <Location /config.js>
    Require all granted
  </Location>

    ProxyPreserveHost on
ProxyPass /http-bind http://localhost:5280/http-bind/
ProxyPassReverse /http-bind http://localhost:5280/http-bind/

    ProxyPreserveHost on
ProxyPass /forum http://192.168.1.5/forum
ProxyPassReverse /forum http://192.168.1.5/forum

  RewriteEngine on
  RewriteRule ^/([a-zA-Z0-9]+)$ /index.html
  Include /etc/letsencrypt/options-ssl-apache.conf
  SSLCertificateFile /etc/letsencrypt/live/example.com-0001/full$
SSLCertificateKeyFile /etc/letsencrypt/live/example.com-0001/pri$
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

现在,我想要做的是为Apache的reverseproxy配置添加一个例外,以便http://example.com/forum重定向到同一网络中另一台机器上托管的另一个网站,例如{{3} }}。 (已编辑以在配置中添加信息 - 不工作)

Apache的配置不是我的强项,所以你必须对我温柔。我尝试简单地更改设置/ http-bind的反向代理的部分,通过将其重定向到我的论坛URL并且它有点工作(没有脚本运行)所以它给了我希望它应该可以没有重新完全配置设置。

如果我有任何其他信息,请告诉我。

干杯!

  • 修改:添加了反向代理信息,以便从http://192.168.1.5/forum链接到我的论坛192.168.1.5/forum
  • 编辑2:删除带有Alias for / forum的行,并从反向代理配置的末尾删除了“/”。

1 个答案:

答案 0 :(得分:0)

您需要在配置中修改以下几项内容:

- 删除 if(![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"testApp.linking://?"]]){ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"App is not available!" message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [alert show]; } 行,这与你想要实现的目标相矛盾

- 为Alias /forum ... URI添加ProxyPass指令:

/forum

- 通过添加条件,确保您的重写规则(否则会重写对ProxyPreserveHost on ProxyPass /forum http://192.168.1.5/forum ProxyPassReverse /forum http://192.168.1.5/forum 的任何请求)不会对/index.html执行:

/forum

RewriteEngine on RewriteCond %{REQUEST_URI} !/forum RewriteRule ^/([a-zA-Z0-9]+)$ /index.html 正常工作,因为它与正则表达式/http-bind

不匹配