Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache反向代理和ShinyProxy_Apache_Websocket_Shiny_Reverse Proxy_Shinyproxy - Fatal编程技术网

Apache反向代理和ShinyProxy

Apache反向代理和ShinyProxy,apache,websocket,shiny,reverse-proxy,shinyproxy,Apache,Websocket,Shiny,Reverse Proxy,Shinyproxy,我编写了一个web应用程序,并使用将其部署到服务器上。通过IP地址和端口8080直接访问应用程序可以正常工作。但是,我需要将其连接到URL。ShinyProxy上有一个关于它如何与Nginx一起工作的解释: server { listen 80; server_name shinyproxy.yourdomain.com; rewrite ^(.*) https://$server_name$1 permanent;

我编写了一个web应用程序,并使用将其部署到服务器上。通过IP地址和端口8080直接访问应用程序可以正常工作。但是,我需要将其连接到URL。ShinyProxy上有一个关于它如何与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文件应该是什么样子吗?如何将不需要用户自动验证的应用程序连接到URL(例如,上面提到的shinyproxy.yourdomain.com)?

如果您有websocket端点的唯一URL,只需加载mod_proxy_wstunel并首先以该流量为目标。在下面的示例中/sly/ws是websocket端点:

ProxyPassMatch ^/(Silly/ws)$ ws://localhost:9080/$1
ProxyPass / http://localhost:9080/
Apache的当前版本不能很好地处理单个URL同时用于未升级和升级流量的情况。如果出现这种情况,您可以在任何代理URL上有条件地使用这样的代码段来执行WebSocket:

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/

回答得很好。谢谢我不知道我必须加载mod_proxy_wstunel。