erseco / alpine-moodle

Moodle docker image based on Alpine Linux
https://hub.docker.com/r/erseco/alpine-moodle
MIT License
42 stars 33 forks source link

SITE_URL with custom port #57

Closed jjrbfi closed 10 months ago

jjrbfi commented 11 months ago

Hi, first thanks for this job, which is great and very useful!

I'm trying to use a custom port and I got an error because it keeps redirecting in a loop, I don't know why.

Here I used: http://192.168.1.240:8021 https://github.com/erseco/alpine-moodle/blob/72e655debfe2bca23bcd33bb1a6cf5d2510b83c7/docker-compose.yml#L25

Here I changed 80 to 8021 https://github.com/erseco/alpine-moodle/blob/72e655debfe2bca23bcd33bb1a6cf5d2510b83c7/docker-compose.yml#L49

Do you know if there is something else I have to modify to get it redirecting correctly?

[EDIT1] JFYI, I modified only the port redirection and I deleted from the SITE_URL. It loads the website but without CSS and so...

[EDIT2] Error example:


image


image

Thanks

erseco commented 11 months ago

Hi @jjrbfi

In order to resolve the redirect loop issue you're facing while trying to use a custom port (8021) for your setup, you need to make three crucial modifications in your configuration:

  1. Update SITE_URL: Change the SITE_URL value to reflect the custom port you're using, i.e., set it to http://localhost:8021.

  2. Enable Reverse Proxy: Set the REVERSEPROXY setting to true. This adjustment will help in handling the redirections properly through the reverse proxy.

  3. Port Mapping: Update the port mapping to 8021:8080 in your docker-compose.yml file to ensure that the traffic on port 8021 on your host machine is correctly forwarded to port 8080 on the Docker container.

By making these changes, your setup should be able to handle the custom port without falling into a redirection loop.

Please confirm that it works :)

jjrbfi commented 11 months ago

It worked fine! Thanks so much for that :)

Just last question. I would like to use Let's encrypt in order to have HTTPS. Do I need to modify erseco/alpine-php-webserver ir order to do so, or you have done something for it?

I'm asking that, because I saw the variable called: SSLPROXY So probably I can place the certificates somewhere to have it working as well.

Gracias nuevamente. Saludos!

erseco commented 10 months ago

Glad to hear that the previous solution worked for you!

Regarding your new query, the SSLPROXY variable that you mentioned is a flag to indicate that SSL termination is happening elsewhere, like on a proxy or a load balancer, before requests reach your web server. This is common in setups where there is an SSL/TLS termination proxy in front of the actual web server.

To set up HTTPS, there are indeed several paths you could take:

  1. Certbot: Certbot is a free and open-source tool that can automatically obtain and install SSL certificates from Let's Encrypt. You can run Certbot in a separate Docker container and configure it to work with your erseco/alpine-php-webserver. Here’s a guide on how to use Certbot with Docker: Certbot Docker Guide.

  2. Caddy: Caddy is a web server that can also act as a reverse proxy with automatic HTTPS. You can set up Caddy to proxy requests to your erseco/alpine-php-webserver and handle the SSL/TLS termination. Check out the Caddy 2 documentation for more details.

  3. Nginx Proxy Manager: Nginx Proxy Manager is an intuitive GUI built on top of the Nginx web server to manage host forwarding, SSL certificate provisioning, and other proxying tasks. You can find more information here: Nginx Proxy Manager Documentation.

  4. Traefik: Traefik is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. It has built-in support for automatic SSL certificate provisioning from Let’s Encrypt. Here’s the link to Traefik's Documentation.

Each of these solutions will allow you to set up HTTPS with Let's Encrypt for your server without needing to modify your erseco/alpine-php-webserver setup. They all provide a mechanism for obtaining and renewing SSL certificates and can handle the SSL/TLS termination for your server.

It would be best to choose the solution that aligns well with your current setup and your level of comfort and expertise with these technologies.