Open kg4iae opened 6 years ago
Soon after I wrote this, I figured it out. In case anyone else needs the "Magic" here it is:
<VirtualHost *:80>
ServerName shell.MYSITE.com
ProxyPreserveHost On
RewriteEngine On
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://localhost:57575%{REQUEST_URI} [P]
ProxyPass / "http://localhost:57575/"
ProxyPassReverse / "http://localhost:57575"
</VirtualHost>
Hi kg4iae, I'm trying to do kind of the same thing but what I want to do is reroute the local port to a url on the same apache server. For example, http://localhost:8080 goes to the regular tomcat webpage. http://localhost:8080/butterfly/ should go to the butterfly login but I have not been able to get it to work successfully. It seems like you've gone down this path and I don't know where I should look to next. I have it almost working with (I'm using port 1234 for butterfly)
ProxyPass /butterfly/ http://localhost:1234
ProxyPassReverse /butterfly/ http://localhost:1234
ProxyRequests On
<Proxy *>
Allow from all
</Proxy>
but I just get a blank box. The page source looks like this -
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Butterfly - A web terminal based on websocket and tornado">
<meta name="author" content="Mounier Florian">
<link rel="shortcut icon" href="/static/images/favicon.png?v=02b0894b1d5c47b396f56cd32e80618d">
<title>Butterfly</title>
<link href="/static/main.css?v=7c790174f2a0759d49793fd6555b9bcd" rel="stylesheet" id="style">
</head>
<body spellcheck="false"
data-force-unicode-width="no"
data-root-path=""
data-session-token=9ee218e2-a008-4043-9446-23fd7687a6e0>
<textarea id="input-helper">
</textarea>
<div id="input-view" class="hidden">
</div>
<div id="popup" class="hidden">
</div>
<script src="/static/html-sanitizer.js?v=c54621161aedf5faa8aeb98dd347acf1"></script>
<script src="/static/main.min.js?v=37e0af9dab7248eb6f3377954880558b"></script>
<script src="/static/ext.min.js?v=1d344e3fd2547af2f8ff74a43bd37079"></script>
<script src="/local.js"></script>
<div id="packed"></div>
<div id="term"></div>
</body>
</html>
Absolutely any ideas from anyone would be greatly appreciated. I've been banging my head against the wall about this for a few days now. Thanks all.
@dbiscan
Did you finally get this working? I'm trying to configure a reverse proxy in the same way and can't get it to work.
Thanks!
Sorry I didn't comment sooner. I just found the email notification from GitHub hidden in a folder I don't check.
Anyway, you have to use rewrite rules since Butterfly uses web sockets. Apache Proxy doesn't play well with sockets.
Copy the lines I shared above into a config file (butterfly.conf). Put it into your /etc/apache2/sites-available folder. Change ServerName, and if necessary butterfly port. I'm using the default 57575.
Run the a2ensite command to enable the new site.
Modify your DNS to include a CNAME record for something like 'shell.yoursite.com' -> 'www.yoursite.com'
You should be able to access the site by using: http://shell.yoursite.com
I tried to get it work using a virtual path, like you did, but never got that working.
Good luck.
Jon
Has anyone gotten this to work behind an Apache server. I've been working on it for days, and can't seem to get it to work.
Right now I get 400 errors on the WebSocket Connections. I can provide more information if anyone wants it.
My Apache config looks like:
ProxyPass / http://localhost:57575/ ProxyPassReverse / http://localhost:57575/
I've tried several things to get WS to play nice, but so far they have all failed.