Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apache #165

Open
kg4iae opened this issue Apr 20, 2018 · 5 comments
Open

Apache #165

kg4iae opened this issue Apr 20, 2018 · 5 comments

Comments

@kg4iae
Copy link

kg4iae commented Apr 20, 2018

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.

@kg4iae
Copy link
Author

kg4iae commented Apr 20, 2018

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>
```




@dbiscan
Copy link

dbiscan commented Jun 25, 2018

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.

@LANGi-AT
Copy link

@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!

@kg4iae
Copy link
Author

kg4iae commented Oct 11, 2018 via email

@Sp1l
Copy link

Sp1l commented Sep 17, 2024

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>

As of Apache 2.4.47, this can be simplified to:

<VirtualHost *:80>
ServerName shell.MYSITE.com
ProxyPreserveHost On
ProxyPass / "http://localhost:57575/" upgrade=websocket
ProxyPassReverse / "http://localhost:57575/"
</VirtualHost>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants