我正在尝试将运行正常的NodeJS应用程序从运行Nginx的专用服务器迁移到另一个运行Apache2的服务器。

这是我的Nginx配置文件

server {
  listen 80;
  server_name example.com;

  root /home/user/myapp;

  location / {
    proxy_pass http://example.com:9000;
  }

  location /logs {
    autoindex on;
  }
}


这是我的Apache2配置文件

<VirtualHost *:80>
DocumentRoot /home/user/myapp

ProxyRequests off

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

<Location />
  ProxyPass http://example.com:9000/
  ProxyPassReverse http://example.com:9000/
</Location>

<Directory /home/user/myapp/logs>
  Options +Indexes
</Directory>

</VirtualHost>


NodeJS应用程序可在两个http服务器上运行,但是我只能使用Nginx获取列表目录http://example.com/logs,而不能使用NodeJS响应的Apache2

Cannot GET /logs/


Apache2配置文件中缺少什么吗?显然,每个Apache2 mod均已启用proxy_http proxyautoindex

最佳答案

添加ProxyPass /logs !可行!

<VirtualHost *:80>
DocumentRoot /home/user/myapp
ProxyRequests off

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

ProxyPass /logs !

<Location />
    ProxyPass http://example.com:9000/
    ProxyPassReverse http://example.com:9000/
</Location>

<Directory /home/user/myapp/logs>
    Options +Indexes
</Directory>

</VirtualHost>

关于node.js - 带有Apache和目录列表的NodeJS,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27067924/

10-13 09:34