Build instructions
- Install SBT: https://www.scala-sbt.org/1.x/docs/Setup.html
- Run:
sbt assembly
- Copy
target/scala-2.13/maschinendeck-spaceapi.jar
- Run with
java -jar maschinendeck-spaceapi.jar
Sample nginx configuration
server {
listen 80;
server_name state.maschinendeck.org;
return 301 https://$host$request_uri;
}
server {
server_name state.maschinendeck.org;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://127.0.0.1:5000;
proxy_intercept_errors on;
}
listen 443 ssl;
ssl_certificate fullchain.pem;
ssl_certificate_key privkey.pem;
include options-ssl-nginx.conf;
ssl_dhparam ssl-dhparams.pem;
}
Sample systemd configuration
[Unit]
Description=SpaceAPI
Wants=network-online.target
After=network.target network-online.target
[Service]
WorkingDirectory=/home/spaceapi
ExecStart=/usr/bin/java -jar /home/spaceapi/maschinendeck-spaceapi.jar
User=spaceapi
Type=simple
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target