################################# # openHABian NGINX Confiuration # ################################# ## Redirection #server { # listen 80; server_name localhost; return 301 https://$server_name$request_uri; #} ## Reverse Proxy to openHAB server { # listen 80; listen 443 ssl; server_name localhost; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; # Cross-Origin Resource Sharing. #CORS add_header 'Access-Control-Allow-Origin' 'http://localhost:8080/rest'; add_header 'Access-Control-Allow_Credentials' 'true'; add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH'; ## Secure Certificate Locations ssl_certificate /etc/ssl/certs/openhab.crt; ssl_certificate_key /etc/ssl/certs/openhab.key; location / { proxy_pass http://localhost:8080/; # proxy_buffering off; # openHAB supports non-buffering specifically for SSEs now proxy_set_header Host $http_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 $scheme; ## Password Protection auth_basic "Username and Password Required"; auth_basic_user_file /etc/nginx/.htpasswd; } ## Let's Encrypt webroot location #WEBROOT location /.well-known/acme-challenge/ { #WEBROOT root /var/www/localhost; #WEBROOT } } # vim: filetype=conf