How to configure your website with nginx, but of course you can use apache if you prefer ...
Go into /etc/nginx/modules-available and create the following testapi file (need sudo) :
server {
server_name testapi.mydomain.com;
location / {
proxy_pass http://0.0.0.0:2024$request_uri;
}
}
Here the testapi.mydomain.com should be the domain that points to the IP address of your server. Once it's done, you can create a symbolic link to this file in /etc/nginx/modules-enabled. Then run :
sudo nginx -t
sudo systemctl reload nginx
sudo systemctl restart nginx
Then, you can launch the TestAPI website by going into the folder of the TestAPI code :
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:2024
🔔 Note that the used port (here
2024) should be the same in thenginxconfiguration file and thegunicorncommand.
You can test that everything runs well by typing opening a browser at testapi.mydomain.com (adapt to your domain name) and see if you can access the website.