
Sou novo no proxypass. Digamos que esta seja a nossa configuração:
<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
Já que fornecemos isso para o Apache
SSLCertificateFile /etc/letsencrypt/live/www.xzos.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.xzos.net/privkey.pem
Não deveríamos precisar usá-los no servidor websocket em execução ws://127.0.0.1:1080/ray/
também, correto?
Mesmo que possamos fazer isso, o Apache lida com isso, certo? e é redundante fazer isso duas vezes, especialmente porque este é um servidor local, eu acho. Acho que se fizermos isso, ws://127.0.0.1:1080/ray/
será necessário que wss://127.0.0.1:1080/ray/
dentro desse servidor websocket forneçamos as mesmas chaves de certificado.
Responder1
Usar o proxyPass para fazer proxy para um ouvinte não seguro no host local ainda pode expor uma superfície de ataque. Você está preocupado com alguém farejando tráfego no host local? Se eu fosse uma pessoa nefasta com o acesso apropriado, poderia tcpdump na interface de loopback na porta 1080 e ler o tráfego. Se você usar wss: // será mais difícil fazê-lo. Eu usaria TLS em ambos os links, a menos que houvesse um motivo técnico para não fazê-lo ou se eu estivesse depurando o aplicativo e precisasse obter mais informações durante esse processo.
Responder2
Posso adicionar meus dois centavos.
Vamos nos concentrar em <LocationMatch "/ray/">
. Como o Apache deve reconhecer o caminho /ray/
se ele estiver encapsulado em um canal criptografado por TLS? É claro que o Apache precisa lidar com o TLS para descriptografar o handshake http e ver GET /whatever/
, e então decidir se ele corresponde ao local.