Apache2 Config Suggestion addition to docs #110

Closed
opened 2025-11-11 14:06:12 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @oliverbob on GitHub (Dec 21, 2023).

Is your feature request related to a problem? Please describe.
For developers who are comfortable with Apache but have difficulty running it with SSL on reverse proxy. Here is the easiest setup:

Clone this rep: Ollama-Webui

git clone https://github.com/ollama-webui/ollama-webui.git

docker build -t ollama-webui .

docker run -d -p 3000:8080 -e OLLAMA_API_BASE_URL=https://example.com/ollama/api --name ollama-webui --restart always ollama-webui
47840bcf80a103da648471ac93b91cd207cf02e5f508c3a3bb0dbf4dfd00fef5

Describe the solution you'd like

example.com.conf:

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com

    ProxyPass / http://example.com:3000/
    ProxyPassReverse / http://example.com:3000/
    ErrorLog ${APACHE_LOG_DIR}/example_error.log
    CustomLog ${APACHE_LOG_DIR}/examplei_access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

sudo a2ensite example.com.conf

Run lets encrypt:
sudo certbot --apache -d example.com

example.com-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com

    ProxyPass / http://example.com:3000/ nocanon
    ProxyPassReverse / http://example.com:3000/
    ErrorLog ${APACHE_LOG_DIR}/example_error.log
    CustomLog ${APACHE_LOG_DIR}/example_access.log combined
SSLProxyEngine on
RewriteEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

Reload Apache2:

sudo systemctl reload apache2

Make sure that ports 80, 443 and 3000 are whitelisted in ufw as well as publicly visible/unblocked from your ISP or host provider.

Describe alternatives you've considered
The Caddy example file can also be used, but make sure it is not conflicting with Apache.

Additional context
This assumes Ollama Web UI is installed on a server running Apache2.

Update:

The following is a working configuration in my system

 ProxyRequests Off
 ProxyPreserveHost On
 ProxyAddHeaders On
 
 ProxyPass / http://example.com:3000/ nocanon
 ProxyPassReverse / http://example.com:3000/
 SSLProxyEngine on

 <Location "/ollama/api">
     ProxyPass http://example.com:11434/api nocanon
     ProxyPassReverse http://example.com:11434/api/
 </Location>

 #set the location for the version: /api/v1
 <Location "/api/v1">
     ProxyPass http://example.com:3000/api/v1 nocanon
     ProxyPassReverse http://example.com:3000/api/v1
 </Location>

Enjoy!

Originally created by @oliverbob on GitHub (Dec 21, 2023). **Is your feature request related to a problem? Please describe.** For developers who are comfortable with Apache but have difficulty running it with SSL on reverse proxy. Here is the easiest setup: Clone this rep: [Ollama-Webui](https://github.com/ollama-webui/ollama-webui.git) `git clone https://github.com/ollama-webui/ollama-webui.git` `docker build -t ollama-webui .` ``` docker run -d -p 3000:8080 -e OLLAMA_API_BASE_URL=https://example.com/ollama/api --name ollama-webui --restart always ollama-webui 47840bcf80a103da648471ac93b91cd207cf02e5f508c3a3bb0dbf4dfd00fef5 ``` **Describe the solution you'd like** example.com.conf: ``` <VirtualHost *:80> ServerName example.com ServerAlias www.example.com ProxyPass / http://example.com:3000/ ProxyPassReverse / http://example.com:3000/ ErrorLog ${APACHE_LOG_DIR}/example_error.log CustomLog ${APACHE_LOG_DIR}/examplei_access.log combined RewriteEngine on RewriteCond %{SERVER_NAME} =example.com [OR] RewriteCond %{SERVER_NAME} =www.example.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost> ``` sudo a2ensite example.com.conf Run lets encrypt: `sudo certbot --apache -d example.com` example.com-le-ssl.conf ``` <IfModule mod_ssl.c> <VirtualHost *:443> ServerName example.com ServerAlias www.example.com ProxyPass / http://example.com:3000/ nocanon ProxyPassReverse / http://example.com:3000/ ErrorLog ${APACHE_LOG_DIR}/example_error.log CustomLog ${APACHE_LOG_DIR}/example_access.log combined SSLProxyEngine on RewriteEngine on SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> </IfModule> ``` Reload Apache2: `sudo systemctl reload apache2` Make sure that ports 80, 443 and 3000 are whitelisted in ufw as well as publicly visible/unblocked from your ISP or host provider. **Describe alternatives you've considered** The Caddy example file can also be used, but make sure it is not conflicting with Apache. **Additional context** This assumes Ollama Web UI is installed on a server running Apache2. Update: The following is a working configuration in my system ``` ProxyRequests Off ProxyPreserveHost On ProxyAddHeaders On ProxyPass / http://example.com:3000/ nocanon ProxyPassReverse / http://example.com:3000/ SSLProxyEngine on <Location "/ollama/api"> ProxyPass http://example.com:11434/api nocanon ProxyPassReverse http://example.com:11434/api/ </Location> #set the location for the version: /api/v1 <Location "/api/v1"> ProxyPass http://example.com:3000/api/v1 nocanon ProxyPassReverse http://example.com:3000/api/v1 </Location> ``` Enjoy!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#110