Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use nginx for deployment #61

Closed
TomasTomecek opened this issue Dec 14, 2023 · 9 comments · Fixed by #68
Closed

Use nginx for deployment #61

TomasTomecek opened this issue Dec 14, 2023 · 9 comments · Fixed by #68
Assignees

Comments

@TomasTomecek
Copy link
Collaborator

gunicorn works well but doesn't support 2 domains, which we have

Let's have an nginx in front of guni where we accept connections to both of the domains

Don't forget to create a route for logdetective.com too

@nikromen
Copy link
Member

nikromen commented Dec 14, 2023

hmmm, not sure but I think this could be solved by adding cors to API

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

app.add_middleware(
    CORSMiddleware,
    allow_origins=["https://www.logdetective.com", "https://www.log-detective.com"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

nginx deployment sauce: https://www.uvicorn.org/deployment/#running-behind-nginx https://docs.gunicorn.org/en/latest/deploy.html

@FrostyX
Copy link
Member

FrostyX commented Dec 14, 2023

I know close to nothing about fastapi so you may be right. But CORS are usually related to what addresses can the JavaScript code communicate with.

@nikromen
Copy link
Member

ah so cors won't help.

I also found a way how to "merge" two certificates into one - maybe https://community.letsencrypt.org/t/host-multiple-domains-with-a-single-certificate/20917/4 will help?

@FrostyX FrostyX moved this from Needs triage to In 3 months in CPT Kanban Dec 20, 2023
@TomasTomecek
Copy link
Collaborator Author

The wildcard certs work for subdomains of a single domain, basically *.example.com.

It would be amazing if we could merge the certificates for log-detective and logdetective into a single certificate file.

Also depends if gunicorn could work with such a certificate.

This was referenced Jan 2, 2024
@nikromen nikromen self-assigned this Jan 8, 2024
@nikromen nikromen moved this from In 3 months to In Progress in CPT Kanban Jan 8, 2024
@nikromen
Copy link
Member

nikromen commented Jan 9, 2024

  • redirect to https

@nikromen
Copy link
Member

nikromen commented Jan 9, 2024

tomas managed to merge those certificates \o/ #68

@TomasTomecek
Copy link
Collaborator Author

I think that longterm we'll need a proper web server between the openshift route and the application server (gunicorn) but for now, @nikromen is right that the problem is resolved

@praiskup praiskup moved this from In Progress to Done in CPT Kanban Jan 15, 2024
@praiskup
Copy link
Member

The log-detective now redirects to https automatically, and logdetective redirects to log-detective.com. Only www.log-detective.com -> log-detective.com remains.

@nikromen
Copy link
Member

I think that longterm we'll need a proper web server between the openshift route and the application server (gunicorn) but for now, @nikromen is right that the problem is resolved

I stored my WIP nginx configuration I had so once needed one can take a look and maybe copy something from nikromen@f75fd95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants