Serving Marimo app with Apache2 reverse proxy?
Hi,
just evaluating Marimo, and it looks very nice, but I'm trying to serve an app in a host that is already running an Apache server, so I was hoping to set a Reverse Proxy to Marimo, but so far with no luck. Is there some documentation out there to the right configuration for this situation?
4 Replies
We have a setting to set the proxy https://docs.marimo.io/guides/troubleshooting.html#check-proxy-settings
Can you let me know if this works and if we could update our docs (with maybe a minimal example of your setup)
I had seen that proxy setting option, but I was not sure how to get it to work. In the end, by modifying the Apache server configuration I was able to get it to work nicely (my previous attempts failed apparently because I didn't have the proxy_wstunnel module enabled)
Ah yes we use websockets. Is there anything we can add to our docs for this? Could you share the minimal configuration needed to get it working?
This is my setting to get it to work. In the server where Apache is running, I modify the Apache configuration file to define a VirtualHost as follows:
ProxyPass /marimo http://127.0.0.1:2718/marimo nocanon
ProxyPassReverse /marimo http://127.0.0.1:2718/marimo
ProxyPreserveHost on
# WebSocket support
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/marimo/(.*) "ws://localhost:2718/marimo/$1" [P,L]
# # Additional headers that might be useful
<Location /marimo>
ProxyPassReverseCookiePath / /marimo
RequestHeader set X-Forwarded-Proto "http"
RequestHeader set X-Forwarded-Port "80"
RequestHeader set X-Forwarded-For "%{REMOTE_ADDR}s"
</Location>
and then I start Marimo with:
marimo edit --base-url /marimo
I tried without the --base-url option, but then it looks like some files are not found. Setting --base-rul to /marimo and then adding it in the URL when defining the VirtualHost all works beautifully.