diff --git a/stage2/10-prepare-nginx/01-run.sh b/stage2/10-prepare-nginx/01-run.sh new file mode 100755 index 0000000..a8215b9 --- /dev/null +++ b/stage2/10-prepare-nginx/01-run.sh @@ -0,0 +1,17 @@ +chmod 644 files/nginx.conf +chmod 644 files/mime.types + +mkdir -p ${ROOTFS_DIR}/home/${FIRST_USER_NAME}/nginx +cp files/nginx.conf ${ROOTFS_DIR}/home/${FIRST_USER_NAME}/nginx/nginx.conf +cp files/mime.types ${ROOTFS_DIR}/home/${FIRST_USER_NAME}/nginx/mime.types + +echo "Create same folder structure" +cp -fr files/www ${ROOTFS_DIR}/home/${FIRST_USER_NAME}/nginx +cp -fr files/log ${ROOTFS_DIR}/home/${FIRST_USER_NAME}/nginx +cp -fr files/conf.d ${ROOTFS_DIR}/home/${FIRST_USER_NAME}/nginx + +echo "Fix up permissions of all config files" +on_chroot << EOF +chown -r ${FIRST_USER_NAME}:${FIRST_USER_NAME} /home/${FIRST_USER_NAME} +EOF + diff --git a/stage2/10-prepare-nginx/files/conf.d/default.conf b/stage2/10-prepare-nginx/files/conf.d/default.conf new file mode 100644 index 0000000..91d489e --- /dev/null +++ b/stage2/10-prepare-nginx/files/conf.d/default.conf @@ -0,0 +1,8 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + root /etc/nginx/www; + index index.html; + try_files $uri /index.html; +} diff --git a/stage2/10-prepare-nginx/files/log/.gitkeep b/stage2/10-prepare-nginx/files/log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/stage2/10-prepare-nginx/files/mime.types b/stage2/10-prepare-nginx/files/mime.types new file mode 100644 index 0000000..0d039d8 --- /dev/null +++ b/stage2/10-prepare-nginx/files/mime.types @@ -0,0 +1,139 @@ +types { + + # Data interchange + + application/atom+xml atom; + application/json json map topojson; + application/ld+json jsonld; + application/rss+xml rss; + # Normalize to standard type. + # https://tools.ietf.org/html/rfc7946#section-12 + application/geo+json geojson; + application/xml xml; + # Normalize to standard type. + # https://tools.ietf.org/html/rfc3870#section-2 + application/rdf+xml rdf; + + + # JavaScript + + # Servers should use text/javascript for JavaScript resources. + # https://html.spec.whatwg.org/multipage/scripting.html#scriptingLanguages + text/javascript js mjs; + application/wasm wasm; + + + # Manifest files + + application/manifest+json webmanifest; + application/x-web-app-manifest+json webapp; + text/cache-manifest appcache; + + + # Media files + + audio/midi mid midi kar; + audio/mp4 aac f4a f4b m4a; + audio/mpeg mp3; + audio/ogg oga ogg opus; + audio/x-realaudio ra; + audio/x-wav wav; + audio/x-matroska mka; + image/bmp bmp; + image/gif gif; + image/jpeg jpeg jpg; + image/jxr jxr hdp wdp; + image/png png; + image/svg+xml svg svgz; + image/tiff tif tiff; + image/vnd.wap.wbmp wbmp; + image/webp webp; + image/x-jng jng; + video/3gpp 3gp 3gpp; + video/mp4 f4p f4v m4v mp4; + video/mpeg mpeg mpg; + video/ogg ogv; + video/quicktime mov; + video/webm webm; + video/x-flv flv; + video/x-mng mng; + video/x-ms-asf asf asx; + video/x-ms-wmv wmv; + video/x-msvideo avi; + video/x-matroska mkv mk3d; + + # Serving `.ico` image files with a different media type + # prevents Internet Explorer from displaying then as images: + # https://github.com/h5bp/html5-boilerplate/commit/37b5fec090d00f38de64b591bcddcb205aadf8ee + + image/x-icon cur ico; + + + # Microsoft Office + + application/msword doc; + application/vnd.ms-excel xls; + application/vnd.ms-powerpoint ppt; + application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; + application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; + + + # Web fonts + + font/woff woff; + font/woff2 woff2; + application/vnd.ms-fontobject eot; + font/ttf ttf; + font/collection ttc; + font/otf otf; + + + # Other + + application/java-archive ear jar war; + application/mac-binhex40 hqx; + application/octet-stream bin deb dll dmg exe img iso msi msm msp safariextz; + application/pdf pdf; + application/postscript ai eps ps; + application/rtf rtf; + application/vnd.google-earth.kml+xml kml; + application/vnd.google-earth.kmz kmz; + application/vnd.wap.wmlc wmlc; + application/x-7z-compressed 7z; + application/x-bb-appworld bbaw; + application/x-bittorrent torrent; + application/x-chrome-extension crx; + application/x-cocoa cco; + application/x-java-archive-diff jardiff; + application/x-java-jnlp-file jnlp; + application/x-makeself run; + application/x-opera-extension oex; + application/x-perl pl pm; + application/x-pilot pdb prc; + application/x-rar-compressed rar; + application/x-redhat-package-manager rpm; + application/x-sea sea; + application/x-shockwave-flash swf; + application/x-stuffit sit; + application/x-tcl tcl tk; + application/x-x509-ca-cert crt der pem; + application/x-xpinstall xpi; + application/xhtml+xml xhtml; + application/xslt+xml xsl; + application/zip zip; + text/calendar ics; + text/css css; + text/csv csv; + text/html htm html shtml; + text/markdown md markdown; + text/mathml mml; + text/plain txt; + text/vcard vcard vcf; + text/vnd.rim.location.xloc xloc; + text/vnd.sun.j2me.app-descriptor jad; + text/vnd.wap.wml wml; + text/vtt vtt; + text/x-component htc; + +} diff --git a/stage2/10-prepare-nginx/files/nginx.conf b/stage2/10-prepare-nginx/files/nginx.conf new file mode 100644 index 0000000..0955b51 --- /dev/null +++ b/stage2/10-prepare-nginx/files/nginx.conf @@ -0,0 +1,23 @@ +user nginx; +worker_processes 1; + +error_log /etc/nginx/log/error.log warn; +pid /etc/nginx/log/nginx.pid; + +events { + worker_connections 1337; +} +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /etc/nginx/log/access.log main; + sendfile on; + keepalive_timeout 65; + + include /etc/nginx/conf.d/*.conf; +} diff --git a/stage2/10-prepare-nginx/files/www/index.html b/stage2/10-prepare-nginx/files/www/index.html new file mode 100644 index 0000000..557db03 --- /dev/null +++ b/stage2/10-prepare-nginx/files/www/index.html @@ -0,0 +1 @@ +Hello World