question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

deployment within apache as reverse proxy

See original GitHub issue

hey man, just a quick information, maybe it’s useful for someone else. I run an Apache https webserver as reverseproxy and had some difficulties with the connection upgrade to websockets - but now it’s running correct with the following config:

activate needed apache modules: a2enmod proxy proxy_http proxy_html proxy_wstunnel filter rewrite substitute

# webssh.conf
#
# https://mydomain.org/ssh 
# Config for WebSSH Portal
##

<Location /ssh >
	ProxyPass  http://127.0.0.1:8888
       	ProxyPassReverse http://127.0.0.1:8888

# for websocket stuff
	RewriteEngine On
	RewriteCond %{HTTP:Upgrade}  ^WebSocket$ [NC, OR]
        RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC, OR]
        RewriteRule .*  ws://localhost:8888/ws$1 [P,L]

# rewrite response html to fix paths
       	AddOutputFilterByType SUBSTITUTE text/html
       	Substitute "s|static/js/|/ssh/static/js/|i"
       	Substitute "s|static/css/|/ssh/static/css/|i"
       	Substitute "s|static/img/|/ssh/static/img/|i"
</Location>

Also i created a systemd service to ensure webssh is running vi /etc/systemd/system/webssh.service with following content:

[Unit]
Description=Python WebSSH 
After=syslog.target network.target
StartLimitBurst=5, StartLimitIntervalSec=10

[Service]
ExecStart=/path/to/webssh_env/bin/wssh --address=127.0.0.1 --origin=https://mydomain.org  --port=8888 --log-file-prefix=/var/log/webssh.log 
ExecReload=/bin/kill -HUP $MAINPID
Type=simple
PIDFile=/var/run/webssh.pid
Restart=on-failure
RestartSec=1

[Install]
WantedBy=multi-user.target

systemctl daemon-reload && systemctl enable webssh.service && systemctl start webssh.service

regards!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:6
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
tevkarcommented, Nov 1, 2020

Yet another working example as a virtual host:

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName  <hostname>

        ProxyPass / http://<ip-address>:8888/
        ProxyPassReverse / http://<ip-address>:8888/

        RewriteEngine On
        RewriteCond %{HTTP:Upgrade} websocket [NC]
        RewriteCond %{HTTP:Connection} upgrade [NC]
        RewriteRule ^/?(.*) "ws://<ip-address>:8888/$1" [P,L]

        ErrorLog ${APACHE_LOG_DIR}/<hostname>.error.log
        CustomLog ${APACHE_LOG_DIR}/<hostname>.access.log combined

SSLCertificateFile /etc/letsencrypt/live/<hostname>/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/<hostname>/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
3reactions
Jamstahcommented, Apr 9, 2021

If you get an error about Cross origin not being allowed, add ProxyPreserveHost On to your config.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to setup an Apache reverse proxy server example
Reverse proxy setup steps · Install Apache and the origin servers · Apache Tomcat app deployment · Apache mod_proxy library · Apache proxypass ......
Read more >
How To Use Apache HTTP Server As Reverse-Proxy Using ...
In this DigitalOcean article, we are going to see set up Apache on Ubuntu 13 and use it as a reverse-proxy to welcome...
Read more >
Configuring Apache HTTP Server as a reverse proxy for ... - IBM
Uncomment these modules: LoadModule proxy_module modules/mod_proxy.so · Go to the SSL configuration section, which starts with #Secure (SSL/TLS) connections .
Read more >
Apache 2.4 as a Reverse Proxy | By Michael Whittle
In order to demonstrate this you will need to deploy two Apache servers as per the tutorial above. One will be the reverse...
Read more >
Configure Apache HTTP Server as Reverse Proxy for brXM
Configure the Apache HTTP Server ("httpd") as a reverse proxy for the CMS and delivery tier web applications. Background. When deploying a Hippo...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found