首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >应用程序在子目录下运行,但需要8080端口访问,无法找到反向代理。

应用程序在子目录下运行,但需要8080端口访问,无法找到反向代理。
EN

Server Fault用户
提问于 2017-02-15 16:47:38
回答 2查看 2.1K关注 0票数 1

我对管理服务器非常陌生,所以请容忍我。

我有一个来自Microsoft的云服务器(不是自愿的),运行Ubuntu16.04和Apache2.4.18。我有多个应用程序(/omeka,/wordpress等)运行在web子目录中,我可以通过任何web浏览器访问这些应用程序,并且不需要任何特定的端口代理或转发。我试图在另一个web子目录(/archivesspace)中运行另一个应用程序(/archivesspace)。该应用程序在不同端口有多个交互点:

本地主机:8089/-后端 localhost:8080/ - staff interface localhost:8081/ - public interface localhost:8090/ - Solr admin console

我安装得也一样成功。我可以判断,因为当通过SSH连接到服务器时,我可以使用$ curl localhost:8080,输出是AS主页的HTML。

我的netstat显示:

代码语言:javascript
复制
Proto  Recv-Q  Send-Q  Local Address  Foreign Address  State   PID
tcp6        0       0  :::8080        :::*             LISTEN  1985/java
tcp6        0       0  :::8081        :::*             LISTEN  1985/java
tcp6        0       0  :::8089        :::*             LISTEN  1985/java
tcp6        0       0  :::8090        :::*             LISTEN  1985/java

我不能从浏览器上访问任何这些端口。我总是得到一个ERR_EMPTY_RESPONSE错误。

我试着和ArchivesSpace的人讨论这个问题,他们的最后一句话基本上是“将Apache设置为反向代理”。所以我试着这么做却没有运气。我希望这里有人能帮忙。以下是我到目前为止在我的1000-default.conf文件中用于反向代理的内容,只是想让其中一个端口(8080)正常工作。

代码语言:javascript
复制
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
</VirtualHost>

Listen 8080

<VirtualHost *:8080>
    ProxyHTMLStripComments on
    ProxyRequests off
    SetOutputFilter proxy-html
    ProxyHTMLDoctype XHTML
    ProxyPreserveHost On

    ServerName http://server.net/archivesspace

<Location />
    ProxyPass http://server.net:8080
    ProxyPassReverse http://server.net:8080
    Order allow,deny
    Allow from all
</Location>
</VirtualHost>

我启用了所有这些Apache:proxy, proxy_ajp, proxy_http, rewrite, deflate, headers, proxy_balancer, proxy_connect, proxy_html

我显然做错了什么,我只是不知道是什么。我甚至不完全确定我需要的合适的URL是什么。我假设是server.net:8081 (或者可能是server.net:8081/archivesspace ?)应该带你去公共界面。理想情况下,它将是server.net/archivesspace。反向代理是解决这一问题的正确途径吗?

apache-2.4标记的说明是发布apache2ctl -S的输出,如下所示。

代码语言:javascript
复制
[Wed Feb 15 16:34:59.401845 2017] [proxy_html:notice] [pid 3722] AH01425: I18n support in mod_proxy_html requires mod_xml2enc. Without it, non-ASCII characters in proxied pages are likely to display incorrectly.
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.2.0.4. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   10.2.0.4 (/etc/apache2/sites-enabled/000-default.conf:1)
*:8080                 server.net/archivesspace (/etc/apache2/sites-enabled/000-default.conf:34)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex proxy: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

请让我知道,如果有任何额外的信息,我可以提供,以帮助确定我的问题。谢谢你能提供的任何指导。

EN

回答 2

Server Fault用户

发布于 2017-02-16 15:17:38

太感谢你了,帕特里克!这招成功了。我删除了VirtualHost *:80块之外的所有内容,并在其中添加了以下内容:

代码语言:javascript
复制
<Location /archivesspace>
    ProxyPass http://localhost:8081
    ProxyPassReverse http://localhost:8081
    Order allow,deny
    Allow from all
</Location>

<Location /archivesspace/admin>
    ProxyPass http://localhost:8080
    ProxyPassReverse http://localhost:8080
    Order allow,deny
    Allow from all
</Location>

同样值得注意的是,这两个Location块的顺序很重要。如果首先列出8080/admin,则8081端口需要在/archivesspace (即/archivesspace/home)下面有一个子目录,这并不理想。将8081放在第一位,只允许访问/archivesspace。

但是,现在我可以通过浏览器访问页面了,看起来所有的CSS和图像都丢失了。但这完全是另一个问题,我可能需要开始一个新的职位,因为如果我不能解决它。

更新:计算出CSS的内容。在config/config.rb文件中,需要更改以下内容:

代码语言:javascript
复制
AppConfig[:frontend_proxy_url] = "http://server.net/archivesspace/admin"
AppConfig[:public_proxy_url] = "http://server.net/archivesspace"
票数 1
EN

Server Fault用户

发布于 2017-02-15 22:50:09

通过说VirtualHost *:8080,您可以告诉Apache在这个端口上侦听,这是不可能的,因为您的Java应用程序已经监听了它。相反,您需要在VirtualHost *:80块中将带有ProxyPass/ProxyPassReverse的<Location /ArchivesSpaces/staff>这样的行添加到服务器(或本地主机) :8080在Location块中,并以相同的方式添加到其他3个端口。您可以自由选择任何您想要的位置路径。

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/832742

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档