-
-
Notifications
You must be signed in to change notification settings - Fork 12
Installation with Nginx
Andrey Gagarin edited this page Sep 14, 2020
·
5 revisions
Install the Nginx webserver and the necessary modules.
sudo apt-get update
sudo apt-get install nginx
Create a file /etc/nginx/sites-available/001-site.conf with the following contents, replacing your.site.com with the DNS name of your site.
server {
listen 80;
server_name your.site.com;
}
Create a link:
ln -s /etc/nginx/sites-available/001.conf /etc/nginx/sites-enabled/
Check if all is correct:
nginx -t
Reload nginx:
systemctl reload nginx
Install certbot on you server. If you have fresh version of Ubuntu or Debian:
sudo apt-get update
sudo apt-get install certbot python-certbot-nginx
Obtaining a certificate:
certbot --nginx -d your.site.com
Change your /etc/nginx/sites-available/001-site.conf to following:
upstream xabber {
server 127.0.0.1:8000;
}
server {
server_name your.site.com;
location / {
proxy_pass http://xabber;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass_header X-CSRF-TOKEN;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-NginX-Proxy true;
}
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/your.site.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your.site.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
if ($host = your.site.com) {
return 301 https://$host$request_uri;
}
listen 80;
server_name your-site.com;
return 404;
}
Check if all is correct:
nginx -t
Reload nginx:
systemctl reload nginx