
저는 Proxypass를 처음 사용합니다. 이것이 우리의 구성이라고 가정해 보겠습니다.
<IfModule mod_ssl.c>
<VirtualHost *:443>
# 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
ServerName www.xzos.net
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias xzos.net
SSLCertificateFile /etc/letsencrypt/live/www.xzos.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.xzos.net/privkey.pem
<LocationMatch "/ray/">
ProxyPass ws://127.0.0.1:1080/ray/ upgrade=WebSocket
ProxyAddHeaders Off
ProxyPreserveHost On
RequestHeader set Host %{HTTP_HOST}s
RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
</LocationMatch>
</VirtualHost>
</IfModule
우리는 이것을 Apache에 제공했기 때문에
SSLCertificateFile /etc/letsencrypt/live/www.xzos.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.xzos.net/privkey.pem
실행 중인 웹소켓 서버에서도 이를 사용할 필요가 없습니다 ws://127.0.0.1:1080/ray/
. 맞나요?
우리는 그렇게 할 수 있지만 아파치가 그것을 제대로 처리합니까? 그리고 이것이 로컬 서버이기 때문에 특별히 두 번 수행하는 것은 중복되는 것 같습니다. 그렇게 하려면 해당 웹소켓 서버 내부에서 동일한 인증서 키를 제공 ws://127.0.0.1:1080/ray/
해야 한다고 생각합니다.wss://127.0.0.1:1080/ray/
답변1
localhost의 보안되지 않은 수신기로 프록시하기 위해 ProxyPass를 사용하면 여전히 공격 표면이 노출될 수 있습니다. 누군가가 localhost에서 트래픽을 스니핑하는 것에 대해 걱정하시나요? 내가 적절한 액세스 권한을 가진 사악한 사람이라면 포트 1080의 루프백 인터페이스에서 tcpdump를 실행하고 트래픽을 읽을 수 있습니다. wss://를 사용한다면 그렇게 하기가 더 어려울 것입니다. 기술적인 이유가 없거나 애플리케이션을 디버깅 중이고 해당 프로세스 중에 추가 정보를 얻어야 하는 경우가 아니면 두 링크 모두에서 TLS를 사용합니다.
답변2
2센트를 더할 수 있어요.
에 집중합시다 <LocationMatch "/ray/">
. /ray/
TLS 암호화 채널에 캡슐화된 경우 Apache는 경로를 어떻게 인식해야 합니까 ? 물론 Apache는 http 핸드셰이크를 해독하고 확인한 GET /whatever/
다음 위치와 일치하는지 결정하기 위해 TLS를 처리해야 합니다.