fastapi/full-stack-fastapi-template

Deploying on a machine with nginx

awaisjafar opened this issue · 3 comments

Having a hard time trying to deploy this on a GCP machine that has nginx setup and already serving a couple of websites. Is there a guide that i can follow or do i have to prune the docker-compose files?

Trying to install it on a server with plesk so having a similar issue - I think its because nginx and apache blocking port 443 and 80

Is there a way to let traefik listen on 8081 (secure) and 8080 non secure?

@awaisjafar What's the exact issue you are facing with gcp + nginx ?

  1. Is the request reaching nginx ? Are you getting nginx access logs
  2. docker pruning is our of context but if you see lots of dangling docker images you should prune.

Hey @awaisjafar @PhilippWu I don't think the current issue you are facing is linked to GCP, nginx or Plesk specifically but most likely from your understanding of how Traefik works.

As mentioned by @sourabhsinha396 it would be great to have a bit more context on your respective issues, I would be happy to help further. In the meantime with the absence of context I will suppose that you followed the deployment documentation of repo and that you are using the current docker-compose.yml file to deploy the stack.

The docker-compose.yml file in this template is designed with the assumption that the stack is not directly exposed on the server. Instead, Traefik acts as the public-facing interface, managing access to the services within the stack.

In your case, @awaisjafar, it seems your GCP instance uses Nginx as the public interface. To make this work, you have two options depending on how you want to configure your services:

  1. Connect Nginx to the Traefik Proxy
    • Modify your Nginx configuration to route traffic to the Traefik proxy.
    • Ensure Traefik is configured to expose the desired services to Nginx.
    • Be cautious with port configuration to avoid conflicts with other services or websites already hosted on your machine.

This approach allows you to retain Traefik’s features, such as automatic SSL certificate management, but requires careful configuration of Nginx to work alongside Traefik.

  1. Bypass Traefik and Use Nginx Directly
    • Modify your Nginx configuration to route traffic directly to your services, bypassing Traefik entirely.
    • Update the docker-compose.yml file to expose the services you need on appropriate ports.

While this simplifies the network setup, it means you’ll need to handle SSL certificates (for HTTPS) manually or configure Nginx to manage them, which can add complexity to your deployment.

Final Recommendation

If you’re already familiar with Traefik, option 1 is generally preferable as it leverages Traefik’s strengths (like SSL automation). However, if your current Nginx setup is well-established (or not editable) and you want to minimize changes, option 2 might be more straightforward.

PS: Keep in mind that this answer may be a bit off topic since the initial post does not provide with a lot of context 🫣