Python和tomcat在同一台机器上

2024-05-16 04:34:46 发布

您现在位置:Python中文网/ 问答频道 /正文

使用sec-web-httpd。 python代码有api:host/v0/auth/sessions/blablba。。。 java代码有api:host/v0/auth/users/blablabla。。。。 机器上有一个conf文件,其中包含python api的以下内容:

 ProxyPass                    /v0/auth/sessions http://localhost:8098/v0/auth/sessions
 ProxyPassReverse     /v0/auth/sessions http://localhost:8098/v0/auth/sessions

对于java api:

^{pr2}$

现在: 当我访问PythonAPI时,我得到了很好的响应,但是当我试图访问JavaAPI时,我得到了“[]”状态代码是200,但我应该得到一个不同的响应。在

有什么想法吗?在


Tags: 代码authapiweblocalhosthttphostsec
2条回答

我执行了类似的任务,并将以下apache配置文件放入config for java应用程序:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin "mail@example.com"
    ServerName example.com
    ServerAlias www.example.com`

    ProxyRequests off
    ProxyPreserveHost on

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

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

</VirtualHost>

请注意,http://example.com:8080/将打开java应用程序。它不是http://example.com:8080/app/。Java应用程序放在/var/lib/tomcat7/webapps/dir的根目录根.jar(至于我的雄猫)。在

在我们的服务器中,我们运行Apache作为代理服务器,这里是一个示例,希望它能对您有所帮助。在

<IfModule mod_proxy.c>
ProxyRequests On
ProxyVia On


<Proxy http://localhost:8080/service>
        AddDefaultCharset off
        Order allow,deny
        Allow from all
</Proxy>

<Proxy http://localhost:8080/foo>
        AddDefaultCharset off
        Order allow,deny
        Allow from all
</Proxy>


<Location "/service">

    Order deny,allow
    Deny from all

    ProxyPass http://localhost:8080/service
    ProxyPassReverse http://localhost:8080/service
</Location>

<Location "/foo">

    Order deny,allow
    Deny from all

    ProxyPass http://localhost:8080/foo
    ProxyPassReverse http://localhost:8080/foo
</Location>

</IfModule>

相关问题 更多 >