Skip to content

Instantly share code, notes, and snippets.

@sansal54
Last active May 11, 2020 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sansal54/843760eb38d3e3ba1203b667742f02d4 to your computer and use it in GitHub Desktop.
Save sansal54/843760eb38d3e3ba1203b667742f02d4 to your computer and use it in GitHub Desktop.
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