大网数据广告活动
服务器运维问答

Apache doesn't listen on all ports configured with virtual host and reverse proxy

· 52CE 我爱测

I have a host (Ubuntu 16.04) and a virtual machine on it. I want to use apache to forward different ports to the VM with the reverse proxy modul. The problem is, that apache doesn't listen on all configured ports. I have the foll…

问题原文

原帖链接 · Tibor Nagy · CC BY-SA 4.0

I have a host (Ubuntu 16.04) and a virtual machine on it. I want to use apache to forward different ports to the VM with the reverse proxy modul. The problem is, that apache doesn't listen on all configured ports.

I have the following settings in /etc/apache2/sites-enabled/moni1.softxs.ch:

<VirtualHost *:80>
    ServerName          moni1.softxs.ch
    Redirect            301 / https://moni1.softxs.ch/
</VirtualHost>

<VirtualHost *:443>
    ServerName          moni1.softxs.ch
    ProxyPreserveHost   On
    ProxyRequests       Off
    ProxyPass           / http://172.16.3.101:80/ retry=0
    ProxyPassReverse    / http://172.16.3.101/
    SSLCertificateFile /etc/letsencrypt/live/moni1.softxs.ch/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/moni1.softxs.ch/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateChainFile /etc/letsencrypt/live/moni1.softxs.ch/chain.pem
</VirtualHost>

<VirtualHost *:3000>
    ServerName          moni1.softxs.ch
    ProxyPreserveHost   On
    ProxyRequests       Off
    ProxyPass           / http://172.16.3.101:3000/ retry=0
    ProxyPassReverse    / http://172.16.3.101/
</VirtualHost>

<VirtualHost *:3010>
    ServerName          moni1.softxs.ch
    ProxyPreserveHost   On
    ProxyRequests       Off
    ProxyPass           / http://172.16.3.101:3010/ retry=0
    ProxyPassReverse    / http://172.16.3.101/
</VirtualHost>

I can see with netstat, that apache doesn't listen on port 3010. No idea, why.

$ netstat -nlptu | grep apache2
tcp6       0      0 :::80                   :::*                    LISTEN      32252/apache2   
tcp6       0      0 :::3000                 :::*                    LISTEN      32252/apache2   
tcp6       0      0 :::443                  :::*                    LISTEN      32252/apache2 

The port is free, I can listen on it with nc. All other reverse proxy setting are working as expected.

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

Somewhere in your Apache configuration, you must have matching Listen directives for each port you want to listen to:

 Listen 3000
 Listen 3010

It appears that you already have one, but not the other.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。