-
Notifications
You must be signed in to change notification settings - Fork 19
nginx
The bare WSGI server is fine for local use, but a real HTTP server such as nginx and Apache might be your best choice if you are deploying SilverDict to the cloud. There are plenty of guides around the web on how to set up nginx to host a web site, so I will not go into details here. But do make sure you at least have made the nginx default page show up before proceeding.
Everything you need is inside server/build
. If you do not plan to deploy SilverDict to the root of your domain, you will need to change the homepage
field in client/package.json
to the path you want to deploy to. (Do not forget to change the server address in client/src/config.js
.) Then you have to run yarn build
yourself. The files will be generated in client/build
.
Move the files generated in the previous step to the directory where nginx serves files from, e.g. /srv/www/htdocs
on openSUSE. Now try visiting the site. You should see the web UI of SilverDict.
Now we need to configure nginx to proxy requests to the Python WSGI server running at port 2628. Here's a sample config:
server {
server_name example.me www.example.me;
listen 443 ssl reuseport fastopen=10; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.me/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.me/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
root /srv/www/htdocs/;
index index.html index.htm;
}
location /api/ {
proxy_pass http://127.0.0.1:2628;
}
}
server {
if ($host = www.example.me) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.me) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 reuseport fastopen=10;
server_name example.me www.example.me;
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_requests 10000;
keepalive_timeout 2h;
return 404; # managed by Certbot
}
The recommended way to start and stop the Python server is to use systemd. Create a file named silverdict.service
in /etc/systemd/system
with the following content:
[Unit]
Description=SilverDict
After=syslog.target network.target
[Service]
User=[Your normal user name]
Group=users
WorkingDirectory=/home/[Your normal user name]/server
ExecStart=python3.11 server.py
Restart=always
RestartSec=120
[Install]
WantedBy=multi-user.target
Then you can start the server with systemctl start silverdict
and stop it with systemctl stop silverdict
.
At this point you should be able to use SilverDict in your browser. If you have any questions, feel free to ask in the issue tracker.