Ver código fonte

HUE-8743 [docker] Basic Nginx docker image to serve files and proxy api

Romain 6 anos atrás
pai
commit
ce7262bdea

+ 1 - 1
tools/docker/README.md

@@ -10,7 +10,7 @@ Availalable on [Docker Hub](https://hub.docker.com/u/gethue/) as well.
 ## Services
 
 * [Hue](hue)
-
+* [Nginx](nginx)
 
 ## Kubernetes
 

+ 16 - 0
tools/docker/nginx/Dockerfile

@@ -0,0 +1,16 @@
+# Welcome to Hue NGINX (http://gethue.com) Dockerfile
+
+FROM nginx
+LABEL description="Image for Webserver"
+
+COPY --from=gethue/hue:latest /usr/share/hue/build/static/ /usr/share/nginx/html/hue/static
+
+RUN rm /etc/nginx/conf.d/default.conf
+
+COPY tools/docker/nginx/nginx.conf /etc/nginx/nginx.conf
+COPY tools/docker/nginx/hue.conf /etc/nginx/sites-available/hue
+
+RUN mkdir /etc/nginx/sites-enabled
+RUN ln -s /etc/nginx/sites-available/hue /etc/nginx/sites-enabled/hue
+
+EXPOSE 80

+ 16 - 0
tools/docker/nginx/README.md

@@ -0,0 +1,16 @@
+
+## Build
+
+    docker build . -t gethue/nginx:latest -f tools/docker/nginx/Dockerfile
+
+## Push
+
+    docker push gethue/nginx:latest
+
+## Run
+
+    docker run -it -p 80:80 gethue/nginx:latest
+
+With a local Hue:
+
+    docker run -it -p 80:80 --network="host" gethue/nginx:latest

+ 33 - 0
tools/docker/nginx/hue.conf

@@ -0,0 +1,33 @@
+server {
+    server_name hue;
+    charset utf-8;
+
+    listen 80;
+
+    # Or if running hue on https://
+    ## listen 8001 ssl;
+    ## ssl_certificate /path/to/ssl/cert;
+    ## ssl_certificate_key /path/to/ssl/key;
+
+    location / {
+        proxy_pass http://localhost:9000;
+
+        # Or if the upstream Hue instances are running behind https://
+        ## proxy_pass https://hue;
+    }
+
+    location /static/ {
+        alias /usr/share/nginx/html/hue/static/;
+
+        expires 30d;
+        add_header Cache-Control public;
+    }
+}
+
+upstream hue {
+    ip_hash;
+
+    # List all the Hue instances here for high availability.
+    server localhost:9000 max_fails=3;
+    #server HUE_HOST2:8888 max_fails=3;
+}

+ 95 - 0
tools/docker/nginx/nginx.conf

@@ -0,0 +1,95 @@
+user www-data;
+worker_processes 4;
+pid /run/nginx.pid;
+
+events {
+	worker_connections 768;
+	# multi_accept on;
+}
+
+http {
+
+	##
+	# Basic Settings
+	##
+
+	sendfile on;
+	tcp_nopush on;
+	tcp_nodelay on;
+	keepalive_timeout 65;
+	types_hash_max_size 2048;
+	# server_tokens off;
+
+	# server_names_hash_bucket_size 64;
+	# server_name_in_redirect off;
+
+	include /etc/nginx/mime.types;
+	default_type application/octet-stream;
+
+	##
+	# Logging Settings
+	##
+
+	access_log /var/log/nginx/access.log;
+	error_log /var/log/nginx/error.log;
+
+	##
+	# Gzip Settings
+	##
+
+	gzip on;
+	gzip_disable "msie6";
+
+	# gzip_vary on;
+	# gzip_proxied any;
+	# gzip_comp_level 6;
+	# gzip_buffers 16 8k;
+	# gzip_http_version 1.1;
+	# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
+
+	##
+	# nginx-naxsi config
+	##
+	# Uncomment it if you installed nginx-naxsi
+	##
+
+	#include /etc/nginx/naxsi_core.rules;
+
+	##
+	# nginx-passenger config
+	##
+	# Uncomment it if you installed nginx-passenger
+	##
+	
+	#passenger_root /usr;
+	#passenger_ruby /usr/bin/ruby;
+
+	##
+	# Virtual Host Configs
+	##
+
+	include /etc/nginx/conf.d/*.conf;
+	include /etc/nginx/sites-enabled/*;
+}
+
+
+#mail {
+#	# See sample authentication script at:
+#	# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
+# 
+#	# auth_http localhost/auth.php;
+#	# pop3_capabilities "TOP" "USER";
+#	# imap_capabilities "IMAP4rev1" "UIDPLUS";
+# 
+#	server {
+#		listen     localhost:110;
+#		protocol   pop3;
+#		proxy      on;
+#	}
+# 
+#	server {
+#		listen     localhost:143;
+#		protocol   imap;
+#		proxy      on;
+#	}
+#}

+ 2 - 2
tools/nginx/README.md

@@ -1,13 +1,13 @@
 
 ## Basic setup
 
-  sudo cp nginx/configs/hue /etc/nginx/sites-available/hue
+    sudo cp nginx/configs/hue /etc/nginx/sites-available/hue
 
     sudo ln -s /etc/nginx/sites-available/hue /etc/nginx/sites-enabled/hue
 
     sudo nginx -t
 
-    sudo service  nginx restart
+    sudo service nginx restart
 
 ## SSL