summaryrefslogtreecommitdiffstats
path: root/nginx-ext-consul
diff options
context:
space:
mode:
Diffstat (limited to 'nginx-ext-consul')
-rw-r--r--nginx-ext-consul/pom.xml131
-rw-r--r--nginx-ext-consul/src/assembly/resources/nginx/conf/mime.types95
-rw-r--r--nginx-ext-consul/src/assembly/resources/nginx/conf/nginx.conf62
-rw-r--r--nginx-ext-consul/src/assembly/resources/nginx/sites-enabled/openresty-consul.conf66
-rw-r--r--nginx-ext-consul/src/assembly/resources/reload.sh26
-rw-r--r--nginx-ext-consul/src/assembly/resources/run.sh47
-rw-r--r--nginx-ext-consul/src/assembly/resources/run4docker.sh39
-rw-r--r--nginx-ext-consul/src/assembly/resources/stop.sh55
8 files changed, 521 insertions, 0 deletions
diff --git a/nginx-ext-consul/pom.xml b/nginx-ext-consul/pom.xml
new file mode 100644
index 0000000..02335b3
--- /dev/null
+++ b/nginx-ext-consul/pom.xml
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 2016 ZTE, Inc. and others.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.onap.msb.discovery</groupId>
+ <artifactId>msb-discovery-parent</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.onap.msb.discovery</groupId>
+ <artifactId>nginx-ext-consul</artifactId>
+ <name>onap/msb/discovery/nginx-ext-consul</name>
+ <packaging>pom</packaging>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <properties>
+ <outputdir>target/assembly/openresty</outputdir>
+ <packageid>nginx-ext-consul</packageid>
+
+
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.msb.discovery</groupId>
+ <artifactId>discovery-ui</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <configuration>
+ <includeEmptyDirs>true</includeEmptyDirs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${outputdir}</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/assembly/resources/</directory>
+ <filtering>false</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <overwrite>true</overwrite>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpacktoNginx</id>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.onap.msb.discovery</groupId>
+ <artifactId>discovery-ui</artifactId>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${outputdir}/nginx/html</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <outputAbsoluteArtifactFilename>true</outputAbsoluteArtifactFilename>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>distribution</id>
+ <phase>package</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target name="distribution">
+ <zip destfile="${version.output}/${packageid}-${project.version}.zip" update="true">
+ <zipfileset dir="target/assembly/" includes="**"/>
+ </zip>
+ <attachartifact file="${version.output}/${packageid}-${project.version}.zip" type="zip"/>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+</plugins>
+</build>
+
+</project>
+
diff --git a/nginx-ext-consul/src/assembly/resources/nginx/conf/mime.types b/nginx-ext-consul/src/assembly/resources/nginx/conf/mime.types
new file mode 100644
index 0000000..09e1b41
--- /dev/null
+++ b/nginx-ext-consul/src/assembly/resources/nginx/conf/mime.types
@@ -0,0 +1,95 @@
+#
+# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+types {
+ text/html html htm shtml;
+ text/css css;
+ text/xml xml rss;
+ image/gif gif;
+ image/jpeg jpeg jpg;
+ application/x-javascript js;
+ application/atom+xml atom;
+
+ text/mathml mml;
+ text/plain txt;
+ text/vnd.sun.j2me.app-descriptor jad;
+ text/vnd.wap.wml wml;
+ text/x-component htc;
+
+ image/png png;
+ image/tiff tif tiff;
+ image/vnd.wap.wbmp wbmp;
+ image/x-icon ico;
+ image/x-jng jng;
+ image/x-ms-bmp bmp;
+ image/svg+xml svg svgz;
+
+ application/java-archive jar war ear;
+ application/json json;
+ application/mac-binhex40 hqx;
+ application/msword doc;
+ application/pdf pdf;
+ application/postscript ps eps ai;
+ application/rtf rtf;
+ application/vnd.ms-excel xls;
+ application/vnd.ms-powerpoint ppt;
+ application/vnd.wap.wmlc wmlc;
+ application/vnd.google-earth.kml+xml kml;
+ application/vnd.google-earth.kmz kmz;
+ application/x-7z-compressed 7z;
+ application/x-cocoa cco;
+ application/x-java-archive-diff jardiff;
+ application/x-java-jnlp-file jnlp;
+ application/x-makeself run;
+ application/x-perl pl pm;
+ application/x-pilot prc pdb;
+ 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 der pem crt;
+ application/x-xpinstall xpi;
+ application/xhtml+xml xhtml;
+ application/zip zip;
+
+ application/octet-stream bin exe dll;
+ application/octet-stream deb;
+ application/octet-stream dmg;
+ application/octet-stream eot;
+ application/octet-stream iso img;
+ application/octet-stream msi msp msm;
+ application/ogg ogx;
+
+ audio/midi mid midi kar;
+ audio/mpeg mpga mpega mp2 mp3 m4a;
+ audio/ogg oga ogg spx;
+ audio/x-realaudio ra;
+ audio/webm weba;
+
+ video/3gpp 3gpp 3gp;
+ video/mp4 mp4;
+ video/mpeg mpeg mpg mpe;
+ video/ogg ogv;
+ video/quicktime mov;
+ video/webm webm;
+ video/x-flv flv;
+ video/x-mng mng;
+ video/x-ms-asf asx asf;
+ video/x-ms-wmv wmv;
+ video/x-msvideo avi;
+} \ No newline at end of file
diff --git a/nginx-ext-consul/src/assembly/resources/nginx/conf/nginx.conf b/nginx-ext-consul/src/assembly/resources/nginx/conf/nginx.conf
new file mode 100644
index 0000000..aec103f
--- /dev/null
+++ b/nginx-ext-consul/src/assembly/resources/nginx/conf/nginx.conf
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#user nobody;
+worker_processes 2;
+worker_rlimit_nofile 65535;
+
+error_log logs/error.log warn;
+pid logs/nginx.pid;
+
+events {
+ #there is normally no need to specify the following directive explicitly
+ #use epoll;
+ worker_connections 10000;
+ multi_accept on;
+}
+
+http {
+ include mime.types;
+ #default_type text/html;
+
+ log_format main '$remote_addr - $remote_user [$time_local] $request_id "$request" '
+ '$status request_processing_time:$request_time upstream_response_time:$upstream_response_time '
+ '"$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
+
+ access_log logs/access.log main;
+ #access_log off;
+
+ sendfile on;
+ tcp_nopush on;
+ tcp_nodelay on;
+
+ server_tokens off;
+
+ keepalive_timeout 120s;
+ keepalive_requests 200;
+ types_hash_max_size 2048;
+
+ #open_file_cache max=200000 inactive=300s;
+ #open_file_cache_valid 300s;
+ #open_file_cache_min_uses 2;
+ #open_file_cache_errors on;
+
+ gzip on;
+ gzip_min_length 1000;
+ gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml;
+
+ include ../sites-enabled/*.conf;
+} \ No newline at end of file
diff --git a/nginx-ext-consul/src/assembly/resources/nginx/sites-enabled/openresty-consul.conf b/nginx-ext-consul/src/assembly/resources/nginx/sites-enabled/openresty-consul.conf
new file mode 100644
index 0000000..f4f19ab
--- /dev/null
+++ b/nginx-ext-consul/src/assembly/resources/nginx/sites-enabled/openresty-consul.conf
@@ -0,0 +1,66 @@
+#set conf for proxy pass
+proxy_connect_timeout 15s;
+proxy_read_timeout 360s;
+proxy_send_timeout 120s;
+proxy_set_header X-Real-IP $remote_addr;
+proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+proxy_set_header Host $host:$server_port;
+proxy_http_version 1.1;
+proxy_set_header Connection "";
+
+upstream apibackend {
+ server 127.0.0.1:8076;
+ keepalive 200;
+}
+upstream consulbackend {
+ server 127.0.0.1:8500;
+ keepalive 200;
+}
+
+
+server {
+ listen 10081;
+
+ location /api/microservices/v1 {
+ proxy_pass http://apibackend;
+ }
+ location /iui/microservices {
+ root html ;
+ }
+
+ location /admin/metrics {
+ proxy_pass http://apibackend;
+ }
+
+ location /api/msdiscover/v1 {
+ rewrite ^/api/msdiscover/v1/(.*) /api/microservices/v1/$1 break;
+ proxy_pass http://apibackend;
+ }
+
+ location /api/catalog/v1 {
+ rewrite ^/api/catalog/v1/(.*) /v1/catalog/$1 break;
+ proxy_pass http://consulbackend;
+ }
+
+ location /api/health/v1 {
+ rewrite ^/api/health/v1/(.*) /v1/health/$1 break;
+ proxy_pass http://consulbackend;
+ }
+
+ location /api/health_check/v1 {
+ rewrite /api/health_check/v1 /v1/status/leader break;
+ proxy_pass http://consulbackend;
+ }
+
+ location = /favicon.ico {
+ log_not_found off;
+ }
+
+ location = /msb {
+ return 302 $scheme://$http_host/iui/microservices/index.html;
+ }
+
+ location / {
+ return 502 ;
+ }
+} \ No newline at end of file
diff --git a/nginx-ext-consul/src/assembly/resources/reload.sh b/nginx-ext-consul/src/assembly/resources/reload.sh
new file mode 100644
index 0000000..240b4b0
--- /dev/null
+++ b/nginx-ext-consul/src/assembly/resources/reload.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+DIRNAME=`dirname $0`
+HOME=`cd $DIRNAME/nginx; pwd`
+_NGINXCMD="$HOME/sbin/nginx"
+
+cd $HOME; pwd
+echo =========== begin to reload ===============
+echo @WORK_DIR@ $HOME
+echo @C_CMD@ $_NGINXCMD -p $HOME/ -s reload
+$_NGINXCMD -p $HOME/ -s reload \ No newline at end of file
diff --git a/nginx-ext-consul/src/assembly/resources/run.sh b/nginx-ext-consul/src/assembly/resources/run.sh
new file mode 100644
index 0000000..a47201e
--- /dev/null
+++ b/nginx-ext-consul/src/assembly/resources/run.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+DIRNAME=`dirname $0`
+HOME=`cd $DIRNAME/nginx; pwd`
+_NGINXCMD="$HOME/sbin/nginx"
+
+LUAJIT_HOME=`cd $DIRNAME/luajit; pwd`
+echo =========== prepare the symbolic links ========================================
+ln -s -f $_NGINXCMD $DIRNAME/bin/openresty
+ln -s -f $LUAJIT_HOME/bin/luajit2.1.0-beta2 $LUAJIT_HOME/bin/luajit
+ln -s -f $LUAJIT_HOME/lib/libluajit-5.1.so.2.1.0 $LUAJIT_HOME/lib/libluajit-5.1.so.2
+ln -s -f $LUAJIT_HOME/lib/libluajit-5.1.so.2.1.0 $LUAJIT_HOME/lib/libluajit-5.1.so
+echo ================================================================================
+
+echo =========== create symbolic link for libluajit-5.1.so.2 ========================================
+LUAJIT_HOME=`cd $DIRNAME/luajit; pwd`
+LUAJIT_FILENAME="$LUAJIT_HOME/lib/libluajit-5.1.so.2"
+LN_TARGET_FILE='/lib/libluajit-5.1.so.2'
+LN_TARGET_FILE64='/lib64/libluajit-5.1.so.2'
+ln -s -f $LUAJIT_FILENAME $LN_TARGET_FILE
+ln -s -f $LUAJIT_FILENAME $LN_TARGET_FILE64
+echo ===============================================================================
+echo HOME=$HOME
+echo _NGINXCMD=$_NGINXCMD
+echo ===============================================================================
+cd $HOME; pwd
+
+
+echo @WORK_DIR@ $HOME
+echo @C_CMD@ $_NGINXCMD -p $HOME/
+$_NGINXCMD -p $HOME/
+
diff --git a/nginx-ext-consul/src/assembly/resources/run4docker.sh b/nginx-ext-consul/src/assembly/resources/run4docker.sh
new file mode 100644
index 0000000..329dabc
--- /dev/null
+++ b/nginx-ext-consul/src/assembly/resources/run4docker.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+DIRNAME=`dirname $0`
+HOME=`cd $DIRNAME/nginx; pwd`
+_NGINXCMD="$HOME/sbin/nginx"
+
+echo =========== create symbolic link for libluajit-5.1.so.2 ========================================
+LUAJIT_HOME=`cd $DIRNAME/luajit; pwd`
+LUAJIT_FILENAME="$LUAJIT_HOME/lib/libluajit-5.1.so.2"
+LN_TARGET_FILE='/lib/libluajit-5.1.so.2'
+LN_TARGET_FILE64='/lib64/libluajit-5.1.so.2'
+ln -s -f $LUAJIT_FILENAME $LN_TARGET_FILE
+ln -s -f $LUAJIT_FILENAME $LN_TARGET_FILE64
+echo ===============================================================================
+
+echo =========== openresty config info =============================================
+echo HOME=$HOME
+echo _NGINXCMD=$_NGINXCMD
+echo ===============================================================================
+cd $HOME; pwd
+
+echo @WORK_DIR@ $HOME
+echo @C_CMD@ $_NGINXCMD -p $HOME/
+$_NGINXCMD -p $HOME/ -g "daemon off;"
+
diff --git a/nginx-ext-consul/src/assembly/resources/stop.sh b/nginx-ext-consul/src/assembly/resources/stop.sh
new file mode 100644
index 0000000..343bff4
--- /dev/null
+++ b/nginx-ext-consul/src/assembly/resources/stop.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+DIRNAME=`dirname $0`
+HOME=`cd $DIRNAME/nginx; pwd`
+_NGINXCMD="$HOME/sbin/nginx"
+
+echo =========== openresty config info =============================================
+echo HOME=$HOME
+echo _NGINXCMD=$_NGINXCMD
+echo ===============================================================================
+cd $HOME; pwd
+
+echo @WORK_DIR@ $HOME
+echo @C_CMD@ $_NGINXCMD -p $HOME/ -s stop
+
+function save_nginx_pid(){
+ nginx_id=`ps -ef | grep nginx | grep $_NGINXCMD | grep -v grep | awk '{print $2}'`
+ echo $nginx_id
+ worker_id_list=`ps -ef | grep nginx | grep $nginx_id | grep "worker process" | awk '{print $2}'`
+ echo $worker_id_list
+}
+
+function kill_nginx_process(){
+ ps -p $nginx_id
+ if [ $? == 0 ]; then
+ kill -9 $nginx_id
+ fi
+
+ for worker_id in $worker_id_list
+ do
+ ps -p $worker_id
+ if [ $? == 0 ]; then
+ echo kill -9 $worker_id
+ kill -9 $worker_id
+ fi
+ done
+}
+save_nginx_pid;
+$_NGINXCMD -p $HOME/ -s stop
+sleep 5
+kill_nginx_process; \ No newline at end of file