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

Changes to address reverse proxy changes #140

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

lucianor
Copy link

This removes the /sshwifty/ folder from the HTML, server code and js configs to address this feature request.

#139

I have not tested this change yet.

lucianor and others added 5 commits June 21, 2023 12:19
Removed /sshwifty/ folder from config
Removed /sshwifty/
Removed /sshwifty/
Removed /sshwifty/
@lucianor lucianor closed this Jun 22, 2023
@lucianor lucianor reopened this Jun 22, 2023
@lucianor
Copy link
Author

Reopening this pull request with additional changes to app.js to account for the pathname during websocket calls.
With these additional changes, one can reverse proxy sshwifty to any folder they desire and by using any web server.
These changes have been tested. I ran sshwifty on my local server and tested a reverse proxy on a valid domain with TLS with multiple web servers (caddy, nginx, apache and lighttpd) on my VPS - both servers are connected with openVPN.

See configs used below, assuming sshwifty would be available under "/ssh" path, and sshwifty is running under 10.8.0.2 port 8182. I listed them by ease to deploy:

caddy - add to your Caddyfile

handle_path /ssh/* {
   reverse_proxy 10.8.0.2:8182
}

lighttpd - any .conf file under /etc/lighttpd/conf-enabled

server.modules += (
        "mod_auth",
        "mod_proxy",
        "mod_setenv"
)

$HTTP["url"] =~ "^/ssh($|/)" {
        proxy.header = ( "upgrade" => "enable", "map-urlpath" => ("/ssh"  => "") )
        proxy.server = ( "" => ( ( "host" => "10.8.0.2", "port" => 8182) ) )
}

nginx - put it under 'default' or another file /etc/nginx/sites-enabled

location /ssh/ {
	rewrite ^/ssh(.*) $1 break;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "upgrade";
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header Host $host;
	proxy_pass http://10.8.0.2:8182;
}

apache 2 - need to enable rewrite and proxy modules and add to a config under /etc/apache2/sites-enabled

  RewriteEngine On
  ProxyPreserveHost On
  ProxyRequests Off

  RewriteEngine On
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /ssh/(.*)           ws://10.8.0.2:8182/$1 [P,L]
  RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  RewriteRule /ssh/(.*)           http://10.8.0.2:8182/$1 [P,L]

  ProxyPass "/ssh" "http://10.8.0.2:8182"
  ProxyPassReverse "/ssh" "http://10.8.0.2:8182"

  ProxyPass "/ssh/socket" "ws:///10.8.0.2:8182/socket"
  ProxyPassReverse "/ssh/socket" "ws://10.8.0.2:8182/socket"

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

Successfully merging this pull request may close these issues.

2 participants