mirror of
https://github.com/miguelgrinberg/microblog.git
synced 2025-12-08 18:02:07 +00:00
Chapter 17: Deployment on Linux (v0.17)
This commit is contained in:
parent
62584d3b03
commit
7f7c99a293
7
Vagrantfile
vendored
Normal file
7
Vagrantfile
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = "ubuntu/jammy64"
|
||||||
|
config.vm.network "private_network", ip: "192.168.56.10"
|
||||||
|
config.vm.provider "virtualbox" do |vb|
|
||||||
|
vb.memory = "2048"
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -7,6 +7,7 @@ load_dotenv(os.path.join(basedir, '.env'))
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'
|
SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'
|
||||||
|
SERVER_NAME = os.environ.get('SERVER_NAME')
|
||||||
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
|
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
|
||||||
'sqlite:///' + os.path.join(basedir, 'app.db')
|
'sqlite:///' + os.path.join(basedir, 'app.db')
|
||||||
MAIL_SERVER = os.environ.get('MAIL_SERVER')
|
MAIL_SERVER = os.environ.get('MAIL_SERVER')
|
||||||
|
|||||||
37
deployment/nginx/microblog
Normal file
37
deployment/nginx/microblog
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
server {
|
||||||
|
# listen on port 80 (http)
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
location / {
|
||||||
|
# redirect any requests to the same URL but on https
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
# listen on port 443 (https)
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
# location of the self-signed SSL certificate
|
||||||
|
ssl_certificate /home/ubuntu/microblog/certs/cert.pem;
|
||||||
|
ssl_certificate_key /home/ubuntu/microblog/certs/key.pem;
|
||||||
|
|
||||||
|
# write access and error logs to /var/log
|
||||||
|
access_log /var/log/microblog_access.log;
|
||||||
|
error_log /var/log/microblog_error.log;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
# forward application requests to the gunicorn server
|
||||||
|
proxy_pass http://localhost:8000;
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /static {
|
||||||
|
# handle static files directly, without forwarding to the application
|
||||||
|
alias /home/ubuntu/microblog/app/static;
|
||||||
|
expires 30d;
|
||||||
|
}
|
||||||
|
}
|
||||||
8
deployment/supervisor/microblog.conf
Normal file
8
deployment/supervisor/microblog.conf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[program:microblog]
|
||||||
|
command=/home/ubuntu/microblog/venv/bin/gunicorn -b localhost:8000 -w 4 microblog:app
|
||||||
|
directory=/home/ubuntu/microblog
|
||||||
|
user=ubuntu
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stopasgroup=true
|
||||||
|
killasgroup=true
|
||||||
Loading…
x
Reference in New Issue
Block a user