重定向 Apache 上的端口

Redirect ports on Apache

我在我的机器上安装了以下设置:

但是我的服务器上有两个 Web 应用程序 运行 它们是:

我最近必须使用 ProxyReverso 才能将 Ethercalc 重定向到 80。因此我的设置:

<VirtualHost *:80>
        ProxyPreserveHost On
    ServerName localhost
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/
    ProxyRequests Off 
    ProxyPass / http://192.168.1.32:8082/
    ProxyPassReverse / http://192.168.1.32:8082/
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
<Location /teste>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
AuthUserFile /etc/apache2/site1/.htpasswd
AuthName "Password Protected Area"
AuthType Basic
Require valid-user
</Location>
<Location /teste/edit>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Deny from all
Allow from 192.168.12.31
</Location>
<Directory /var/www/phpipam>
Options FollowSymLinks
AllowOverride all
Require all granted
</Directory>
    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

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


</VirtualHost>

当访问我的本地主机时,它会重定向到 Ethercalc,但我希望在我输入时这样:例如:https://localhost:81,我会被重定向到 Phpipam。

有人知道这是否可行吗?

您可以使用两个虚拟主机,但您不必为此使用端口号。您通常有两个 IP 地址供您使用,即 127.0.0.1 和 127.0.1.1。将一个用于 PHPiPam,另一个用于 EtherCalc。那你就不用代理了。

现在您正在将所有请求重定向到 Ehtercalc。您只需为以 www.ethercalc.te.

开头的请求执行此操作

您在 /etc/hosts 文件中设置了两个域(www.ethercalc.te 和 www.phpipam.te),为它们创建两个虚拟主机,启用它们,然后就可以开始了。

在 Apache 中你有一个 port.conf。在该文件中,您可以添加端口 81 作为 Apache 应该侦听的端口。您可以为端口 81 创建一个虚拟主机,然后将其映射到您的 PHPipam 服务器。

在我的文件 /etc/hosts 中,我将第一个条目设置为: 127.0.0.1 本地主机 www.tandt.lb tandt.lb

这是虚拟主机:

<VirtualHost www.tandt.lb:80>
    ServerName www.tandt.lb
    ServerAlias tandt.lb *.tandt.lb
    ServerAdmin lbergman@tandt.lb
    DocumentRoot /var/www/Websites/TestAndTools
    RewriteEngine On
    RewriteOptions Inherit


    <Directory /var/www/Websites/TestAndTools>
        Options -Indexes FollowSymLinks MultiViews
        AllowOverride FileInfo
        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}/tandt/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug

    CustomLog ${APACHE_LOG_DIR}/tandt/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

确保在使用 a2ensite 启用此虚拟目录之前创建自定义日志目录....(目录 /etc/apache/sites-available 中的文件名)。