Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Flask + Nginx konfigürasyonu
Assuming flask app is running on http://localhost:5000 with gunicorn and supervisor already setup.
# install nginx and dependencies
$ sudo apt-get install python3-dev nginx
create a new server block configuration file in Nginx’s sites-available directory named cafe_app13:
$ sudo nano /etc/nginx/sites-available/cafe_app13
Open up a server block and tell Nginx to listen on the default port 80. We also need to tell it to use this block for requests for our server’s domain name or IP address:
server {
listen 80;
server_name 192.168.233.128;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
To enable the Nginx server block configuration we’ve just created, link the file to the sites-enabled directory. The syntax is as follows:
$ sudo ln -s /etc/nginx/sites-available/cafe_app13 /etc/nginx/sites-enabled
With the file in that directory, we can test for syntax errors by typing: sudo nginx -t If this does not indicate any issues, we can restart the Nginx process to read our new config:
$ sudo systemctl restart nginx
The last thing we need to do is adjust our firewall to allow access to the Nginx server:
$ sudo ufw allow 'Nginx Full'
You should now be able to go to your server’s domain name or IP address in your web browser and see your app running.
http://server_domain_or_IP
Congratulations!! Your deployment is done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.