背景
我正在开展一个涉及 2 台服务器的项目。服务器 A 是运行 Ubuntu 14.04 的 VPS,具有公共 IP 地址。服务器 B 在端口 8080 上运行 MJPG 服务,没有公共 IP 地址。我通过在服务器 B 上运行以下命令在两台服务器之间创建了反向 ssh 隧道:
ssh <user>@serverA -N -R 8099:localhost:8080
服务器 A 正在运行 apache,它为具有以下配置的站点提供服务(默认 apache vhost)
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# 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
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
我对位于的文件进行了/var/www/html/index.html
如下修改:
<img width=640 height=480 src="http://localhost:8099/?action=stream"/>
问题
上述配置对我来说不起作用。流加载失败。我能够在服务器 A 上执行以下命令并获得恒定的数据流:
curl localhost:8099/?action=stream
但由于某种原因,apache 不会提供该图像。
如果我编辑/etc/ssh/sshd_conf
并添加该行GatewayPorts yes
,我可以通过调整我的图像源来使流正常工作,http://<server_A_public_ip>:8099/?action=stream
但是,这会将流公开。
我也尝试过更改User
和Group
指令以/etc/apache2/apache2.conf
匹配<user>
上面的 ssh 命令,以便以该用户身份启动 apache。但仍然不行。
我希望能够在 serverA:8099 <=> serverB:8080 之间启用 ssh 隧道,但端口 8099 只能由服务器 A 本身访问。任何人都不能通过 URL 公开访问该流http://<server_A_public_ip>:8099
我在这里遗漏了什么明显的东西吗? 有没有人有其他想法可以帮助我找出我的问题所在?