Jon
June 6, 2024, 8:19am
2
Hey @chizuoka ,
Welcome to the community
We consider self hosting n8n to be an advanced configuration option and we rely on your knowledge of the services you want to use around n8n this would include your reverse proxy of choice.
As a starting point though the example below is a minimal example of what needs to be done for Apache.
<VirtualHost *:80>
ServerName n8n.yourdomain.tld
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://172.17.0.1:5678/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://172.17.0.1:5678/$1 [P,L]
ProxyPassReverse / http://n8n.yourdomain.tld
</VirtualHost>
You may be able to find more information in the posts below:
Caveat, I am running n8n in docker but i also have 100+ virtual web hosts in my apache config on the same server.
This worked for me to get n8n running on the same box.
I had to add in the Proxy modules for Apache
Using Ubuntu Linux 22.04 this is
a2enmod proxy
a2enmod proxy_http
a2enmod ssl
Reload the apache configuration’
systemctl reload apache2
I then set up 2 new virtual host in apache.
<VirtualHost *:443>
ServerName anything.example.com
ServerAdmin webmaster@localhost
S…
Enable Apache module proxy and proxy_wstunnel
sudo a2enmod proxy
sudo a2enmod proxy_wstunnel
edit apache2 conf with the content bellow
sudo vi /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerName n8n.yourdomain.com
RewriteEngine on
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5678/
ProxyPassReverse / http://127.0.0.1:5678/
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade […
Thanks @Jon , I was close but couldn’t have made it work without your help, or at least not without losing a few extra hours! So thank you very much!
Here’s the final solution, if it helps anyone else:
<VirtualHost *:80>
# HTTP -> HTTPS
ServerName n8n.domain.com
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:443>
ServerName n8n.domain.com
SSLEngine On
…