我编写了一个shiny web应用程序,并使用ShinyProxy将其部署到服务器上。通过IP地址和端口8080直接访问应用程序工作正常。但是,我需要将它连接到一个URL。在ShinyProxy website上,有一个关于它如何与Nginx一起工作的解释:
server {
listen 80;
server_name shinyproxy.yourdomain.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443;
server_name shinyproxy.yourdomain.com;
access_log /var/log/nginx/shinyproxy.access.log;
error_log /var/log/nginx/shinyproxy.error.log error;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/ssl/certs/yourdomain.com.crt;
ssl_certificate_key /etc/ssl/private/yourdomain.com.key;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 600s;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}不幸的是,我需要使用Apache,即Apache/2.4.43 (Debian)。我尝试了各种配置,但都不能正常工作。只需将目标URL连接到服务器上的端口,我就可以首先加载应用程序。尽管在加载应用程序后,屏幕立即变灰,应用程序没有响应。之所以会发生这种情况,是因为简单地将URL链接到IP地址并不能正确说明web套接字的使用。
有人知道正确的Apache文件应该是什么样子吗?如何将不需要用户认证的应用程序连接到网址(例如上面提到的shinyproxy.yourdomain.com)?
发布于 2020-08-10 01:00:20
如果您拥有websocket端点的唯一URL,只需加载mod_proxy_wstunnel并首先确定该流量的目标。在下面的示例中,/Silly/ws是websocket端点:
ProxyPassMatch ^/(Silly/ws)$ ws://localhost:9080/$1
ProxyPass / http://localhost:9080/当前版本的Apache不能很好地处理使用单个URL处理未升级和已升级流量的情况。如果您遇到这种情况,您可以在任何代理URL上有条件地使用如下代码片段执行websockets:
ProxyPass / http://localhost:9080/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://localhost:9080/$1" [P,L]未来的2.4.x版本可能会支持像当前httpd主干这样的简单场景:
ProxyPass / ws:/localhost:9080/
ProxyPass / http://localhost:9080/https://stackoverflow.com/questions/63112223
复制相似问题