--- /dev/null
+#!/bin/bash
+
+# Check input params
+if [ $# -ne 1 ]; then
+ (echo "Usage: $0 common-name") 1>&2
+ exit 1
+fi
+
+# Check running as root
+if [ "$(whoami)" != "root" ]; then
+ (echo "Run $0 as root.") 1>&2
+ exit 1
+fi
+
+echo 'Making the conf dir /usr/share/nginx/conf...'
+mkdir -p /usr/share/nginx/conf
+
+echo Generating the server private key...
+openssl genrsa -out /usr/share/nginx/conf/server.key 2048
+
+echo Generating the CSR...
+openssl req -new -key /usr/share/nginx/conf/server.key \
+-out /usr/share/nginx/conf/server.csr \
+ -subj "/C=AU/ST=WA/L=Perth/O=UWA/OU=Mechatronics/CN=$1"
+
+echo Signing the certificate...
+openssl x509 -req -days 3650 -in /usr/share/nginx/conf/server.csr \
+-signkey /usr/share/nginx/conf/server.key \
+-out /usr/share/nginx/conf/server.crt
+
+
--- /dev/null
+/var/log/mctxserv*.log
+{
+ rotate 36500
+ daily
+ missingok
+ notifempty
+ compress
+ delaycompress
+ sharedscripts
+ postrotate
+ invoke-rc.d rsyslog rotate > /dev/null
+ endscript
+}
+
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
+fastcgi_param COOKIE_STRING $http_cookie;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
server {
- listen 80;
+ #Redirect HTTP to HTTPS
+ listen [::]:80;
+ return 301 https://$host$request_uri;
+}
+
+server {
+ listen 443;
+
+ ssl on;
+ ssl_certificate /usr/share/nginx/conf/server.crt;
+ ssl_certificate_key /usr/share/nginx/conf/server.key;
+
+ ssl_session_timeout 5m;
+
+ ssl_protocols SSLv3 TLSv1;
+ ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
+ ssl_prefer_server_ciphers on;
#Change this to match your root directory
root /usr/share/nginx/www;
}
#Program log
- location ^~ /api/log {
+ location = /api/log {
alias /var/log/mctxserv.log;
default_type text/plain;
}
#Program error log
- location ^~ /api/errorlog {
+ location = /api/errorlog {
alias /var/log/mctxserv-error.log;
default_type text/plain;
}
);
setTimeout(updater, 1000);
}).fail(function (jqXHR) {
- outdiv.text("Failed to retrieve the error log.");
+ if (jqXHR.status === 502 || jqXHR.status === 0) {
+ outdiv.text("Failed to retrieve the error log.");
+ }
+ setTimeout(updater, 1500);
});
};
--- /dev/null
+compile with:
+gcc test.c -lfcgi -o test
+
+Run with:
+spawn-fcgi -p9005 -n ./test
+
+nginx must be configured to pass $http_cookie as an evironment variable named COOKIE
\ No newline at end of file
--- /dev/null
+#include <fcgi_stdio.h>
+#include <stdlib.h>
+int main() {
+ while (FCGI_Accept() >= 0) {
+ printf("Content-type: text\r\n");
+ printf("Set-Cookie: name=value with spaces; and a semicolon\r\n");
+ printf("Set-Cookie: name2=value2\r\n\r\n");
+ printf("Cookie:%s\n", getenv("COOKIE_STRING"));
+ }
+}