From: Sam Moore Date: Mon, 30 Sep 2013 07:37:05 +0000 (+0000) Subject: Merge branch 'master' of https://github.com/szmoore/MCTX3420 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=218c2d77e10b28315864990acbcf55ffe26a76e9;hp=be4e13604e52cdc7986b726124d007a664f534b7;p=matches%2FMCTX3420.git Merge branch 'master' of https://github.com/szmoore/MCTX3420 --- diff --git a/server-configs/gen_ssl_cert.sh b/server-configs/gen_ssl_cert.sh new file mode 100644 index 0000000..1342562 --- /dev/null +++ b/server-configs/gen_ssl_cert.sh @@ -0,0 +1,31 @@ +#!/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 + + diff --git a/server-configs/logrotate.d/mctxserv.conf b/server-configs/logrotate.d/mctxserv.conf new file mode 100644 index 0000000..2208c2a --- /dev/null +++ b/server-configs/logrotate.d/mctxserv.conf @@ -0,0 +1,14 @@ +/var/log/mctxserv*.log +{ + rotate 36500 + daily + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript +} + diff --git a/server-configs/nginx/fastcgi_params b/server-configs/nginx/fastcgi_params index 51aa692..b5b9858 100644 --- a/server-configs/nginx/fastcgi_params +++ b/server-configs/nginx/fastcgi_params @@ -2,6 +2,7 @@ fastcgi_param QUERY_STRING $query_string; 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; diff --git a/server-configs/nginx/sites-enabled/mctxconfig b/server-configs/nginx/sites-enabled/mctxconfig index 82d972a..97e46b6 100644 --- a/server-configs/nginx/sites-enabled/mctxconfig +++ b/server-configs/nginx/sites-enabled/mctxconfig @@ -1,5 +1,21 @@ 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; @@ -65,13 +81,13 @@ server { } #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; } diff --git a/server/run.sh b/server/run.sh index 5c0c61f..4318b39 100755 Binary files a/server/run.sh and b/server/run.sh differ diff --git a/testing/MCTXWeb/public_html/static/mctx.gui.js b/testing/MCTXWeb/public_html/static/mctx.gui.js index 606c0be..247484d 100644 --- a/testing/MCTXWeb/public_html/static/mctx.gui.js +++ b/testing/MCTXWeb/public_html/static/mctx.gui.js @@ -193,7 +193,10 @@ $.fn.setErrorLog = function () { ); 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); }); }; diff --git a/testing/cookie-test/readme.txt b/testing/cookie-test/readme.txt new file mode 100644 index 0000000..fb52249 --- /dev/null +++ b/testing/cookie-test/readme.txt @@ -0,0 +1,7 @@ +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 diff --git a/testing/cookie-test/test.c b/testing/cookie-test/test.c new file mode 100644 index 0000000..7f88239 --- /dev/null +++ b/testing/cookie-test/test.c @@ -0,0 +1,10 @@ +#include +#include +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")); + } +}