aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorswarupn <swarupnpvt@gmail.com>2018-11-06 19:36:20 +0530
committerswarupn <swarupnpvt@gmail.com>2018-11-12 20:32:51 +0530
commit6b11ecb07f5612819635eb48ec26d94d1fc64cf1 (patch)
tree6a4b31c4a8f06644e8102d3da2bbf8b6deb67409
parent07b448c987619766da5c12235f3f693f3cd60209 (diff)
Chore: NGINX demo with multi stack and multi protocol (vpp-hoststck, lwip, kernel) (tcp, udp)
Change-Id: I3feb3a88b75b8292e0d7df77e8ed41ee0e2fc0aa Signed-off-by: swarupn <swarupnpvt@gmail.com>
-rw-r--r--demo/nginx_proxy/README.md19
-rw-r--r--demo/nginx_proxy/demo-1/Vagrantfile98
-rw-r--r--demo/nginx_proxy/demo-1/adjust_hugepage.sh14
-rwxr-xr-xdemo/nginx_proxy/demo-1/apply_patch.sh9
-rw-r--r--demo/nginx_proxy/demo-1/demo_2stack.patch29
-rw-r--r--demo/nginx_proxy/demo-1/module_config.json38
-rw-r--r--demo/nginx_proxy/demo-1/proxy_nginx.conf81
-rw-r--r--demo/nginx_proxy/demo-1/rd_config.json27
-rw-r--r--demo/nginx_proxy/demo-1/setup_proxy.sh54
-rw-r--r--demo/nginx_proxy/demo-1/setup_upstream.sh45
-rw-r--r--demo/nginx_proxy/demo-1/startup.conf20
-rw-r--r--demo/nginx_proxy/demo-1/upstream_nginx.conf80
-rw-r--r--demo/nginx_proxy/demo-1/vpp_config6
-rw-r--r--demo/nginx_proxy/demo-2/README.md69
-rw-r--r--demo/nginx_proxy/demo-2/Vagrantfile116
-rw-r--r--demo/nginx_proxy/demo-2/adjust_hugepage.sh14
-rwxr-xr-xdemo/nginx_proxy/demo-2/apply_patch.sh9
-rw-r--r--demo/nginx_proxy/demo-2/dem-2-topo.pngbin0 -> 32437 bytes
-rw-r--r--demo/nginx_proxy/demo-2/demo-2.pngbin0 -> 125156 bytes
-rw-r--r--demo/nginx_proxy/demo-2/demo_2stack.patch29
-rw-r--r--demo/nginx_proxy/demo-2/module_config.json38
-rw-r--r--demo/nginx_proxy/demo-2/proxy_nginx.conf33
-rw-r--r--demo/nginx_proxy/demo-2/rd_config.json31
-rw-r--r--demo/nginx_proxy/demo-2/setup_client.sh25
-rw-r--r--demo/nginx_proxy/demo-2/setup_proxy.sh54
-rw-r--r--demo/nginx_proxy/demo-2/setup_udpserver.sh25
-rw-r--r--demo/nginx_proxy/demo-2/setup_upstream.sh44
-rw-r--r--demo/nginx_proxy/demo-2/startup.conf20
-rw-r--r--demo/nginx_proxy/demo-2/udpclient.c50
-rw-r--r--demo/nginx_proxy/demo-2/udpserver.c55
-rw-r--r--demo/nginx_proxy/demo-2/upstream_nginx.conf80
-rw-r--r--demo/nginx_proxy/demo-2/vpp_config6
32 files changed, 1218 insertions, 0 deletions
diff --git a/demo/nginx_proxy/README.md b/demo/nginx_proxy/README.md
new file mode 100644
index 0000000..b8a9705
--- /dev/null
+++ b/demo/nginx_proxy/README.md
@@ -0,0 +1,19 @@
+# Introduction
+DMM (Dual Mode, Multi-protocol, Multi-instance) is to implement a transport agnostic framework for network
+applications that can
+1. Work with both user space and kernel space network stacks
+2. Use different network protocol stacks based on their functional and performance requirements (QOS)
+3. Work with multiple instances of a transport protocol stack.
+
+Following demo directory demonstrates some of these features of DMM.
+Procedures and details of how to run this demo is inside each demo directory.
+
+##demo-1
+
+This demo use NGINX as a reverse proxy server. The server uses lwip as client facing stack and kernel tcp/ip
+stack as upstream server facing stack.
+
+##demo-2
+
+This demo NGINX as a reverse proxy server. The server uses lwip as client facing stack and kernel tcp/ip stack
+as upstream server facing stack for UDP, vpp-hoststack for another updtream server facing stack for TCP. \ No newline at end of file
diff --git a/demo/nginx_proxy/demo-1/Vagrantfile b/demo/nginx_proxy/demo-1/Vagrantfile
new file mode 100644
index 0000000..d3db5e5
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/Vagrantfile
@@ -0,0 +1,98 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+boxes = [
+ {
+ :name => "rproxy-client",
+ :hostname => "rproxy-client",
+ :mem => "1024",
+ :cpu => "1"
+ },
+ {
+ :name => "rproxy-server",
+ :hostname => "rproxy-server",
+ :mem => "1024",
+ :cpu => "1"
+ },
+ {
+ :name => "rproxy-proxy",
+ :hostname => "rproxy-proxy",
+ :mem => "10144",
+ :cpu => "4"
+ }
+]
+
+Vagrant.configure(2) do |config|
+
+ # Pick the right distro and bootstrap, default is ubuntu1604
+ distro = ( ENV['DMM_VAGRANT_DISTRO'] || "ubuntu")
+ if distro == 'centos7'
+ config.vm.box = "puppetlabs/centos-7.2-64-nocm"
+ else
+ config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
+ end
+
+ config.vm.box_check_update = false
+ #ddconfig.ssh.password = vagrant
+ if Vagrant.has_plugin?("vagrant-cachier")
+ config.cache.scope = :box
+ end
+
+ # Define some physical ports for your VMs to be used by DPDK
+ #nics = (ENV['DMM_VAGRANT_NICS'] || "2").to_i(10)
+ #for i in 1..nics
+ # config.vm.network "private_network", type: "dhcp"
+ #end
+
+ if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
+ config.proxy.http = ENV['http_proxy']
+ config.proxy.https = ENV['https_proxy']
+ config.proxy.no_proxy = "localhost,127.0.0.1"
+ end
+
+ config.ssh.forward_agent = true
+ config.ssh.forward_x11 = true
+
+ boxes.each do |opts|
+ config.vm.define opts[:name] do |srv|
+ srv.vm.hostname = opts[:hostname]
+ srv.vm.provider "virtualbox" do |vb|
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
+ vb.customize ["modifyvm", :id, "--memory", opts[:mem]]
+ vb.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
+ end
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh")
+ puts ' '..srv.vm.hostname
+
+ if opts[:name] == "rproxy-proxy"
+ puts 'NGINX Proxy Server, Run nginx in below way '
+ puts 'export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64'
+ puts './DMM/thirdparty/apps/nginx/release/nginx'
+ srv.vm.synced_folder "../../../", "/DMM", type: "rsync"
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"apply_patch.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/build.sh"), :args => "/DMM vagrant"
+ srv.vm.network "private_network", ip: "192.168.50.20"
+ srv.vm.network "private_network", ip: "172.167.50.20"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/start_nstackMain.sh"), :args => "/DMM vagrant"
+ #possibly overwrite by previous script so adjust again
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"setup_proxy.sh"), run: 'always'
+ end
+ if opts[:name] == "rproxy-client"
+ puts 'Client use command: curl http://192.168.50.20'
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.network "private_network", ip: "192.168.50.10"
+ end
+ if opts[:name] == "rproxy-server"
+ puts 'Upstream server '
+
+ srv.vm.synced_folder "./", "/NGINX", type: "rsync"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_upstream.sh"), run: 'always'
+ srv.vm.network "private_network", ip: "172.167.50.30"
+ end
+ end
+ end
+end
diff --git a/demo/nginx_proxy/demo-1/adjust_hugepage.sh b/demo/nginx_proxy/demo-1/adjust_hugepage.sh
new file mode 100644
index 0000000..282e3bd
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/adjust_hugepage.sh
@@ -0,0 +1,14 @@
+#!/bin/bash -x
+hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'})
+if [ "$hugepagesize" == "2048" ]; then
+ pages=3000
+elif [ "$hugepagesize" == "1048576" ]; then
+ pages=5
+fi
+sudo sysctl -w vm.nr_hugepages=$pages
+HUGEPAGES=`sysctl -n vm.nr_hugepages`
+echo "Configured hugepages: $HUGEPAGE"
+if [ $HUGEPAGES != $pages ]; then
+ echo "Warning: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish."
+fi
+
diff --git a/demo/nginx_proxy/demo-1/apply_patch.sh b/demo/nginx_proxy/demo-1/apply_patch.sh
new file mode 100755
index 0000000..84ecc59
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/apply_patch.sh
@@ -0,0 +1,9 @@
+#!/bin/bash -x
+sudo apt-get install patch -y
+cd /DMM/src/
+sudo patch -p2 -i /DMM/demo/nginx_proxy/demo-1/demo_2stack.patch
+if [ $? -ne 0 ]; then
+ echo "Patch Apply failed. Downlaod correct commit. Check README for details."
+ exit -1
+fi
+cd -
diff --git a/demo/nginx_proxy/demo-1/demo_2stack.patch b/demo/nginx_proxy/demo-1/demo_2stack.patch
new file mode 100644
index 0000000..f1bc8d3
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/demo_2stack.patch
@@ -0,0 +1,29 @@
+diff --git a/src/adapt/nstack_dmm_adpt.c b/src/adapt/nstack_dmm_adpt.c
+index d497b80..004975c 100644
+--- a/src/adapt/nstack_dmm_adpt.c
++++ b/src/adapt/nstack_dmm_adpt.c
+@@ -76,7 +76,7 @@ nstack_event_callback (void *pdata, int events)
+ /*event should not notice other process */
+ if ((ep->pid != get_sys_pid ()) && g_same_process)
+ {
+- continue;
++ //continue;
+ }
+
+ sys_arch_lock_with_pid (&ep->lock);
+diff --git a/src/nSocket/nstack/nstack_module.c b/src/nSocket/nstack/nstack_module.c
+index 9566ab8..f692225 100644
+--- a/src/nSocket/nstack/nstack_module.c
++++ b/src/nSocket/nstack/nstack_module.c
+@@ -60,6 +60,11 @@ nstack_get_deploy_type ()
+ if (g_nstack_module_desc[icnt].deploytype > type)
+ {
+ type = g_nstack_module_desc[icnt].deploytype;
++ if (NSTACK_MODEL_TYPE3 == type)
++ {
++ break;
++ }
++
+ }
+ }
+ return type;
diff --git a/demo/nginx_proxy/demo-1/module_config.json b/demo/nginx_proxy/demo-1/module_config.json
new file mode 100644
index 0000000..93ef5f2
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/module_config.json
@@ -0,0 +1,38 @@
+{
+ "default_stack_name": "kernel",
+ "module_list": [
+ {
+ "stack_name": "kernel",
+ "function_name": "kernel_stack_register",
+ "libname": "./",
+ "loadtype": "static",
+ "deploytype": "1",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "0",
+ },
+ {
+ "stack_name": "lwip",
+ "function_name": "nstack_stack_register",
+ "libname": "libnstack.so",
+ "loadtype": "dynmic",
+ "deploytype": "3",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "1",
+ },
+ {
+ "stack_name": "vpp_hoststack",
+ "function_name": "vpphs_stack_register",
+ "libname": "./libdmm_vcl.so",
+ "loadtype": "dynmic",
+ "deploytype": "4",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "2",
+ },
+ ]
+}
diff --git a/demo/nginx_proxy/demo-1/proxy_nginx.conf b/demo/nginx_proxy/demo-1/proxy_nginx.conf
new file mode 100644
index 0000000..05d8d2a
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/proxy_nginx.conf
@@ -0,0 +1,81 @@
+user root;
+worker_processes 1;
+daemon off;
+#error_log logs/error.log;
+#error_log logs/error.log notice;
+#error_log logs/error.log info;
+
+#pid logs/nginx.pid;
+
+
+events {
+ worker_connections 1024;
+}
+
+
+http {
+ include 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 logs/access.log main;
+
+ sendfile on;
+ #tcp_nopush on;
+
+ #keepalive_timeout 0;
+ keepalive_timeout 65;
+
+ #gzip on;
+
+ server {
+ listen 192.168.50.20:80 default_server;
+ server_name 192.168.50.20;
+
+ location / {
+ proxy_bind 172.167.50.20:2020;
+ proxy_pass http://172.167.50.30:80;
+ proxy_set_header X-Real-IP $remote_addr;
+ sendfile off;
+ proxy_buffering off;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ }
+
+ #error_page 404 /404.html;
+
+ # redirect server error pages to the static page /50x.html
+ #
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root html;
+ }
+
+ # proxy the PHP scripts to Apache listening on 127.0.0.1:80
+ #
+ #location ~ \.php$ {
+ # proxy_pass http://127.0.0.1;
+ #}
+
+ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+ #
+ #location ~ \.php$ {
+ # root html;
+ # fastcgi_pass 127.0.0.1:9000;
+ # fastcgi_index index.php;
+ # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
+ # include fastcgi_params;
+ #}
+
+ # deny access to .htaccess files, if Apache's document root
+ # concurs with nginx's one
+ #
+ #location ~ /\.ht {
+ # deny all;
+ #}
+ }
+
+
+}
diff --git a/demo/nginx_proxy/demo-1/rd_config.json b/demo/nginx_proxy/demo-1/rd_config.json
new file mode 100644
index 0000000..71f8919
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/rd_config.json
@@ -0,0 +1,27 @@
+{
+ "ip_route": [
+ {
+ "subnet": "192.168.50.20/32",
+ "stack_name": "lwip",
+ },
+ {
+ "subnet": "192.168.50.10/32",
+ "stack_name": "kernel",
+ },
+ {
+ "subnet": "172.167.50.20/24",
+ "stack_name": "vpp_hoststack",
+ }
+ ],
+ "prot_route": [
+ {
+ "proto_type": "1",
+ "stack_name": "lwip",
+ },
+ {
+ "proto_type": "2",
+ "stack_name": "kernel",
+ }
+ ],
+}
+
diff --git a/demo/nginx_proxy/demo-1/setup_proxy.sh b/demo/nginx_proxy/demo-1/setup_proxy.sh
new file mode 100644
index 0000000..7dc4fa3
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/setup_proxy.sh
@@ -0,0 +1,54 @@
+#########################################################################
+# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+# 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.
+#########################################################################
+#!/bin/bash -x
+
+set -x
+sudo su
+# Clean up build NGINX
+cd /DMM/build/
+
+#Download and compile NGINX
+make NGINX
+#Download and compile vpp-stack
+make vpp-stack
+
+#cp vpp libs
+cp -r /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/vpp_plugins /usr/lib/
+mkdir -p /etc/vpp/
+cp /DMM/demo/nginx_proxy/demo-1/startup.conf /etc/vpp/
+cp /DMM/demo/nginx_proxy/demo-1/vpp_config /etc/vpp/
+cd /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/bin
+#run vpp
+sudo ifconfig enp0s9 down
+./vpp -c /etc/vpp/startup.conf
+
+#cp nginx libs
+cd /DMM/thirdparty/apps/nginx/release
+
+# Move the conf file.
+cp /DMM/demo/nginx_proxy/demo-1/module_config.json /DMM/thirdparty/apps/nginx/release/
+cp /DMM/stacks/lwip_stack/app_conf/nStackConfig.json /DMM/thirdparty/apps/nginx/release/
+cp /DMM/demo/nginx_proxy/demo-1/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/
+cp /DMM/demo/nginx_proxy/demo-1/rd_config.json /DMM/thirdparty/apps/nginx/release/
+mv /DMM/thirdparty/apps/nginx/release/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/nginx.conf
+
+sleep 5
+
+# Run nginx
+cp /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/libdmm_vcl.so /DMM/thirdparty/apps/nginx/release/
+echo "export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64"
+echo "./nginx"
+
+exit 0
diff --git a/demo/nginx_proxy/demo-1/setup_upstream.sh b/demo/nginx_proxy/demo-1/setup_upstream.sh
new file mode 100644
index 0000000..0c2c774
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/setup_upstream.sh
@@ -0,0 +1,45 @@
+#########################################################################
+# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+# 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.
+#########################################################################
+#!/bin/bash -x
+
+set -x
+
+# Download nginx
+cd /NGINX
+wget http://nginx.org/download/nginx-1.14.0.tar.gz
+tar -zxf nginx-1.14.0.tar.gz
+
+#install supportive softwares
+apt-get install -yq libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev
+
+# Compile nginx
+cd nginx-1.14.0
+./configure
+make
+make install
+
+# Move the conf file.
+cd /usr/local/nginx/sbin
+cp -r * /usr/local/sbin
+cp /NGINX/upstream_nginx.conf /usr/local/nginx/conf/
+mv /usr/local/nginx/conf/upstream_nginx.conf /usr/local/nginx/conf/nginx.conf
+
+# Run nginx
+
+cd /usr/local/sbin
+./nginx
+echo "hi"
+exit 0
+
diff --git a/demo/nginx_proxy/demo-1/startup.conf b/demo/nginx_proxy/demo-1/startup.conf
new file mode 100644
index 0000000..616cd88
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/startup.conf
@@ -0,0 +1,20 @@
+unix {
+ log /var/log/vpp/vpp.log
+ cli-listen localhost:5002
+ exec /etc/vpp/vpp_config
+}
+
+api-trace {
+ on
+}
+
+cpu {
+ main-core 2
+}
+
+dpdk {
+ socket-mem 1024
+ uio-driver igb_uio
+ dev 0000:00:09.0
+}
+
diff --git a/demo/nginx_proxy/demo-1/upstream_nginx.conf b/demo/nginx_proxy/demo-1/upstream_nginx.conf
new file mode 100644
index 0000000..3904197
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/upstream_nginx.conf
@@ -0,0 +1,80 @@
+#user nobody;
+worker_processes 1;
+#daemon off;
+
+#error_log logs/error.log;
+#error_log logs/error.log notice;
+#error_log logs/error.log info;
+
+#pid logs/nginx.pid;
+
+
+events {
+ worker_connections 1024;
+}
+
+
+http {
+ include 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 logs/access.log main;
+
+ sendfile on;
+ #tcp_nopush on;
+
+ #keepalive_timeout 0;
+ keepalive_timeout 65;
+
+ #gzip on;
+
+ server {
+ listen 80;
+ #server_name localhost;
+
+ #charset koi8-r;
+
+ #access_log logs/host.access.log main;
+
+ location / {
+ return 200 "Hello from upstream $hostname $server_addr:$server_port. Connect from $http_x_real_ip - $remote_user via $remote_addr:$remote_port at [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent\n";
+ }
+
+ #error_page 404 /404.html;
+
+ # redirect server error pages to the static page /50x.html
+ #
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root html;
+ }
+
+ # proxy the PHP scripts to Apache listening on 127.0.0.1:80
+ #
+ #location ~ \.php$ {
+ # proxy_pass http://127.0.0.1;
+ #}
+
+ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+ #
+ #location ~ \.php$ {
+ # root html;
+ # fastcgi_pass 127.0.0.1:9000;
+ # fastcgi_index index.php;
+ # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
+ # include fastcgi_params;
+ #}
+
+ # deny access to .htaccess files, if Apache's document root
+ # concurs with nginx's one
+ #
+ #location ~ /\.ht {
+ # deny all;
+ #}
+ }
+
+}
diff --git a/demo/nginx_proxy/demo-1/vpp_config b/demo/nginx_proxy/demo-1/vpp_config
new file mode 100644
index 0000000..aaeadfb
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/vpp_config
@@ -0,0 +1,6 @@
+set int state GigabitEthernet0/9/0 up
+set int ip addr GigabitEthernet0/9/0 172.167.50.20/24
+show version
+show version verbose
+show cpu
+show int
diff --git a/demo/nginx_proxy/demo-2/README.md b/demo/nginx_proxy/demo-2/README.md
new file mode 100644
index 0000000..173e93b
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/README.md
@@ -0,0 +1,69 @@
+#demo-2
+## Introduction
+This demo NGINX as a reverse proxy server. The server uses "lwip" for client facing socket and "kernel tcp/ip stack "
+as upstream server facing socket for UDP, "vpp-hoststack" for another updtream server facing stack for TCP.
+
+## Topology
+![demo-2.png](demo-2.png)
+![dem-2-topo.png](dem-2-topo.png)
+## Steps
+####1. Create VMs using vagrant.
+Start demo VMs. Go to dmm/demo/nginx_proxy/demo-2 .
+```
+$ vagrant up
+```
+This command will create 4 VMs namely rproxy-client, rproxy-server1, rproxy-server2 and rproxy-proxy. The memory
+requirement for this demo is 13GB (approx).
+
+####2. Log in to VMs
+Open four terminal and login to VMs.
+```
+$ vagrant ssh <vm-name>
+```
+
+####3. Run Udp server Application at rproxy-server2
+```
+$ vagrant ssh rproxy-server2
+Inside VM
+vagrant@rproxy-server2:~$ sudo su
+root@rproxy-server2:/home/vagrant# cd /UDPSERVER/
+root@rproxy-server2:/UDPSERVER# ./udpserver
+```
+
+####4. Run NGINX proxy server at rproxy-proxy
+```
+$ vagrant ssh rproxy-proxy
+Inside VM
+vagrant@rproxy-proxy:~$ sudo su
+root@rproxy-proxy:/home/vagrant# cd /DMM/thirdparty/apps/nginx/release
+root@rproxy-proxy:/DMM/thirdparty/apps/nginx/release# export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64
+root@rproxy-proxy:/DMM/thirdparty/apps/nginx/release# ./nginx
+```
+####5. Test TCP traffic
+```
+$ vagrant ssh rproxy-client
+vagrant@rproxy-client:~$ cd /CLIENT/
+vagrant@rproxy-client:/CLIENT$ curl http://192.168.50.20
+Hello from upstream rproxy-server1 172.167.50.30:80. Connect from - via 172.167.50.20:15140 at [12/Nov/2018:06:17:25 -0800] GET / HTTP/1.1 200 0 curl/7.47.0
+
+```
+
+####6. Test UDP traffic
+```
+$ vagrant ssh rproxy-client
+vagrant@rproxy-client:~$ cd /CLIENT/
+vagrant@rproxy-client:/CLIENT$ curl http://192.168.50.20
+Hello message sent.
+Server : Hello from server
+```
+#### Notes:
+a. If enable debugs i.e. export NSTACK_LOG_ON=DBG before we run nginx in rroxy-proxy we can find below logs which suggest we use diffrent stack for diffrent ip/protoccol.
+```
+...
+nstack_bind<NSSOC>fd addr Select module]fd=18,addr=192.168.50.20,module=lwip
+...
+nstack_bind<NSSOC>fd addr Select module]fd=22,addr=172.167.50.20,module=vpp_hoststack
+...
+nstack_bind<NSSOC>fd addr Select module]fd=22,addr=182.167.50.20,module=kernel
+```
+b. This demo depends on commit of dmm. Please check commit version of your code. \ No newline at end of file
diff --git a/demo/nginx_proxy/demo-2/Vagrantfile b/demo/nginx_proxy/demo-2/Vagrantfile
new file mode 100644
index 0000000..dbd703a
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/Vagrantfile
@@ -0,0 +1,116 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+boxes = [
+ {
+ :name => "rproxy-client",
+ :hostname => "rproxy-client",
+ :mem => "1024",
+ :cpu => "1"
+ },
+ {
+ :name => "rproxy-server1",
+ :hostname => "rproxy-server1",
+ :mem => "1024",
+ :cpu => "1"
+ },
+ {
+ :name => "rproxy-server2",
+ :hostname => "rproxy-server2",
+ :mem => "1024",
+ :cpu => "1"
+ },
+ {
+ :name => "rproxy-proxy",
+ :hostname => "rproxy-proxy",
+ :mem => "10144",
+ :cpu => "4"
+ }
+]
+
+Vagrant.configure(2) do |config|
+
+ # Pick the right distro and bootstrap, default is ubuntu1604
+ distro = ( ENV['DMM_VAGRANT_DISTRO'] || "ubuntu")
+ if distro == 'centos7'
+ config.vm.box = "puppetlabs/centos-7.2-64-nocm"
+ else
+ config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
+ end
+
+ config.vm.box_check_update = false
+ #ddconfig.ssh.password = vagrant
+ if Vagrant.has_plugin?("vagrant-cachier")
+ config.cache.scope = :box
+ end
+
+ # Define some physical ports for your VMs to be used by DPDK
+ #nics = (ENV['DMM_VAGRANT_NICS'] || "2").to_i(10)
+ #for i in 1..nics
+ # config.vm.network "private_network", type: "dhcp"
+ #end
+
+ if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
+ config.proxy.http = ENV['http_proxy']
+ config.proxy.https = ENV['https_proxy']
+ config.proxy.no_proxy = "localhost,127.0.0.1"
+ end
+
+ config.ssh.forward_agent = true
+ config.ssh.forward_x11 = true
+
+ boxes.each do |opts|
+ config.vm.define opts[:name] do |srv|
+ srv.vm.hostname = opts[:hostname]
+ srv.vm.provider "virtualbox" do |vb|
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
+ vb.customize ["modifyvm", :id, "--memory", opts[:mem]]
+ vb.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
+ end
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh")
+ puts ' '..srv.vm.hostname
+
+ if opts[:name] == "rproxy-proxy"
+ puts 'NGINX Proxy Server, Run nginx in below way '
+ puts 'export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64'
+ puts './DMM/thirdparty/apps/nginx/release/nginx'
+ srv.vm.synced_folder "../../../", "/DMM", type: "rsync"
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"apply_patch.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/build.sh"), :args => "/DMM vagrant"
+ srv.vm.network "private_network", ip: "192.168.50.20"
+ srv.vm.network "private_network", ip: "172.167.50.20"
+ srv.vm.network "private_network", ip: "182.167.50.20"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/start_nstackMain.sh"), :args => "/DMM vagrant"
+ #possibly overwrite by previous script so adjust again
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"setup_proxy.sh"), run: 'always'
+ end
+ if opts[:name] == "rproxy-client"
+ puts 'Client use command for TCP: curl http://192.168.50.20'
+ puts 'Client use command for UDP: ./udpclient'
+ srv.vm.synced_folder "./", "/CLIENT", type: "rsync"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.network "private_network", ip: "192.168.50.10"
+ srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_client.sh"), run: 'always'
+ end
+ if opts[:name] == "rproxy-server1"
+ puts 'Upstream server 1'
+
+ srv.vm.synced_folder "./", "/NGINX", type: "rsync"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_upstream.sh"), run: 'always'
+ srv.vm.network "private_network", ip: "172.167.50.30"
+ end
+ if opts[:name] == "rproxy-server2"
+ puts 'Upstream server 2 '
+
+ srv.vm.synced_folder "./", "/UDPSERVER", type: "rsync"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_udpserver.sh"), run: 'always'
+ srv.vm.network "private_network", ip: "182.167.50.30"
+ end
+ end
+ end
+end
diff --git a/demo/nginx_proxy/demo-2/adjust_hugepage.sh b/demo/nginx_proxy/demo-2/adjust_hugepage.sh
new file mode 100644
index 0000000..282e3bd
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/adjust_hugepage.sh
@@ -0,0 +1,14 @@
+#!/bin/bash -x
+hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'})
+if [ "$hugepagesize" == "2048" ]; then
+ pages=3000
+elif [ "$hugepagesize" == "1048576" ]; then
+ pages=5
+fi
+sudo sysctl -w vm.nr_hugepages=$pages
+HUGEPAGES=`sysctl -n vm.nr_hugepages`
+echo "Configured hugepages: $HUGEPAGE"
+if [ $HUGEPAGES != $pages ]; then
+ echo "Warning: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish."
+fi
+
diff --git a/demo/nginx_proxy/demo-2/apply_patch.sh b/demo/nginx_proxy/demo-2/apply_patch.sh
new file mode 100755
index 0000000..05e8c66
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/apply_patch.sh
@@ -0,0 +1,9 @@
+#!/bin/bash -x
+sudo apt-get install patch -y
+cd /DMM/src/
+sudo patch -p2 -i /DMM/demo/nginx_proxy/demo-2/demo_2stack.patch
+if [ $? -ne 0 ]; then
+ echo "Patch Apply failed. Downlaod correct commit. Check README for details."
+ exit -1
+fi
+cd -
diff --git a/demo/nginx_proxy/demo-2/dem-2-topo.png b/demo/nginx_proxy/demo-2/dem-2-topo.png
new file mode 100644
index 0000000..ad81372
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/dem-2-topo.png
Binary files differ
diff --git a/demo/nginx_proxy/demo-2/demo-2.png b/demo/nginx_proxy/demo-2/demo-2.png
new file mode 100644
index 0000000..604c301
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/demo-2.png
Binary files differ
diff --git a/demo/nginx_proxy/demo-2/demo_2stack.patch b/demo/nginx_proxy/demo-2/demo_2stack.patch
new file mode 100644
index 0000000..f1bc8d3
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/demo_2stack.patch
@@ -0,0 +1,29 @@
+diff --git a/src/adapt/nstack_dmm_adpt.c b/src/adapt/nstack_dmm_adpt.c
+index d497b80..004975c 100644
+--- a/src/adapt/nstack_dmm_adpt.c
++++ b/src/adapt/nstack_dmm_adpt.c
+@@ -76,7 +76,7 @@ nstack_event_callback (void *pdata, int events)
+ /*event should not notice other process */
+ if ((ep->pid != get_sys_pid ()) && g_same_process)
+ {
+- continue;
++ //continue;
+ }
+
+ sys_arch_lock_with_pid (&ep->lock);
+diff --git a/src/nSocket/nstack/nstack_module.c b/src/nSocket/nstack/nstack_module.c
+index 9566ab8..f692225 100644
+--- a/src/nSocket/nstack/nstack_module.c
++++ b/src/nSocket/nstack/nstack_module.c
+@@ -60,6 +60,11 @@ nstack_get_deploy_type ()
+ if (g_nstack_module_desc[icnt].deploytype > type)
+ {
+ type = g_nstack_module_desc[icnt].deploytype;
++ if (NSTACK_MODEL_TYPE3 == type)
++ {
++ break;
++ }
++
+ }
+ }
+ return type;
diff --git a/demo/nginx_proxy/demo-2/module_config.json b/demo/nginx_proxy/demo-2/module_config.json
new file mode 100644
index 0000000..93ef5f2
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/module_config.json
@@ -0,0 +1,38 @@
+{
+ "default_stack_name": "kernel",
+ "module_list": [
+ {
+ "stack_name": "kernel",
+ "function_name": "kernel_stack_register",
+ "libname": "./",
+ "loadtype": "static",
+ "deploytype": "1",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "0",
+ },
+ {
+ "stack_name": "lwip",
+ "function_name": "nstack_stack_register",
+ "libname": "libnstack.so",
+ "loadtype": "dynmic",
+ "deploytype": "3",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "1",
+ },
+ {
+ "stack_name": "vpp_hoststack",
+ "function_name": "vpphs_stack_register",
+ "libname": "./libdmm_vcl.so",
+ "loadtype": "dynmic",
+ "deploytype": "4",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "2",
+ },
+ ]
+}
diff --git a/demo/nginx_proxy/demo-2/proxy_nginx.conf b/demo/nginx_proxy/demo-2/proxy_nginx.conf
new file mode 100644
index 0000000..925e1a9
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/proxy_nginx.conf
@@ -0,0 +1,33 @@
+user root;
+worker_processes 1;
+daemon off;
+#error_log logs/error.log;
+#error_log logs/error.log notice;
+#error_log logs/error.log info;
+
+#pid logs/nginx.pid;
+
+
+events {
+ worker_connections 1024;
+}
+
+stream {
+ upstream stream_tcp {
+ server 172.167.50.30:80;
+ }
+ upstream stream_udp {
+ server 182.167.50.30:53;
+ }
+ server {
+ listen 192.168.50.20:80;
+ proxy_bind 172.167.50.20:2020;
+ proxy_pass stream_tcp;
+ }
+ server {
+ listen 192.168.50.20:53 udp;
+ proxy_bind 182.167.50.20:53;
+ proxy_pass stream_udp;
+ }
+}
+
diff --git a/demo/nginx_proxy/demo-2/rd_config.json b/demo/nginx_proxy/demo-2/rd_config.json
new file mode 100644
index 0000000..45ad585
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/rd_config.json
@@ -0,0 +1,31 @@
+{
+ "ip_route": [
+ {
+ "subnet": "192.168.50.20/32",
+ "stack_name": "lwip",
+ },
+ {
+ "subnet": "192.168.50.10/32",
+ "stack_name": "kernel",
+ },
+ {
+ "subnet": "172.167.50.20/24",
+ "stack_name": "vpp_hoststack",
+ },
+ {
+ "subnet": "182.167.50.20/32",
+ "stack_name": "kernel",
+ }
+ ],
+ "prot_route": [
+ {
+ "proto_type": "1",
+ "stack_name": "lwip",
+ },
+ {
+ "proto_type": "2",
+ "stack_name": "kernel",
+ }
+ ],
+}
+
diff --git a/demo/nginx_proxy/demo-2/setup_client.sh b/demo/nginx_proxy/demo-2/setup_client.sh
new file mode 100644
index 0000000..a0f4363
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/setup_client.sh
@@ -0,0 +1,25 @@
+#########################################################################
+# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+# 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.
+#########################################################################
+#!/bin/bash -x
+
+set -x
+
+# Download nginx
+cd /CLIENT
+
+gcc udpclient.c -o udpclient
+
+exit 0
+
diff --git a/demo/nginx_proxy/demo-2/setup_proxy.sh b/demo/nginx_proxy/demo-2/setup_proxy.sh
new file mode 100644
index 0000000..fc2039c
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/setup_proxy.sh
@@ -0,0 +1,54 @@
+#########################################################################
+# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+# 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.
+#########################################################################
+#!/bin/bash -x
+
+set -x
+sudo su
+# Clean up build NGINX
+cd /DMM/build/
+
+#Download and compile NGINX
+make NGINX
+#Download and compile vpp-stack
+make vpp-stack
+
+#cp vpp libs
+cp -r /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/vpp_plugins /usr/lib/
+mkdir -p /etc/vpp/
+cp /DMM/demo/nginx_proxy/demo-2/startup.conf /etc/vpp/
+cp /DMM/demo/nginx_proxy/demo-2/vpp_config /etc/vpp/
+cd /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/bin
+#run vpp
+sudo ifconfig enp0s9 down
+./vpp -c /etc/vpp/startup.conf
+
+#cp nginx libs
+cd /DMM/thirdparty/apps/nginx/release
+
+# Move the conf file.
+cp /DMM/demo/nginx_proxy/demo-2/module_config.json /DMM/thirdparty/apps/nginx/release/
+cp /DMM/stacks/lwip_stack/app_conf/nStackConfig.json /DMM/thirdparty/apps/nginx/release/
+cp /DMM/demo/nginx_proxy/demo-2/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/
+cp /DMM/demo/nginx_proxy/demo-2/rd_config.json /DMM/thirdparty/apps/nginx/release/
+mv /DMM/thirdparty/apps/nginx/release/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/nginx.conf
+
+sleep 5
+
+# Run nginx
+cp /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/libdmm_vcl.so /DMM/thirdparty/apps/nginx/release/
+echo "export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64"
+echo "./nginx"
+
+exit 0
diff --git a/demo/nginx_proxy/demo-2/setup_udpserver.sh b/demo/nginx_proxy/demo-2/setup_udpserver.sh
new file mode 100644
index 0000000..d684286
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/setup_udpserver.sh
@@ -0,0 +1,25 @@
+#########################################################################
+# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+# 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.
+#########################################################################
+#!/bin/bash -x
+
+set -x
+
+# Download nginx
+cd /UDPSERVER
+
+gcc udpserver.c -o udpserver
+
+exit 0
+
diff --git a/demo/nginx_proxy/demo-2/setup_upstream.sh b/demo/nginx_proxy/demo-2/setup_upstream.sh
new file mode 100644
index 0000000..ee7dbd4
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/setup_upstream.sh
@@ -0,0 +1,44 @@
+#########################################################################
+# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+# 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.
+#########################################################################
+#!/bin/bash -x
+
+set -x
+
+# Download nginx
+cd /NGINX
+wget http://nginx.org/download/nginx-1.14.0.tar.gz
+tar -zxf nginx-1.14.0.tar.gz
+
+#install supportive softwares
+apt-get install -yq libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev
+
+# Compile nginx
+cd nginx-1.14.0
+./configure
+make
+make install
+
+# Move the conf file.
+cd /usr/local/nginx/sbin
+cp -r * /usr/local/sbin
+cp /NGINX/upstream_nginx.conf /usr/local/nginx/conf/
+mv /usr/local/nginx/conf/upstream_nginx.conf /usr/local/nginx/conf/nginx.conf
+
+# Run nginx
+
+cd /usr/local/sbin
+./nginx
+exit 0
+
diff --git a/demo/nginx_proxy/demo-2/startup.conf b/demo/nginx_proxy/demo-2/startup.conf
new file mode 100644
index 0000000..616cd88
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/startup.conf
@@ -0,0 +1,20 @@
+unix {
+ log /var/log/vpp/vpp.log
+ cli-listen localhost:5002
+ exec /etc/vpp/vpp_config
+}
+
+api-trace {
+ on
+}
+
+cpu {
+ main-core 2
+}
+
+dpdk {
+ socket-mem 1024
+ uio-driver igb_uio
+ dev 0000:00:09.0
+}
+
diff --git a/demo/nginx_proxy/demo-2/udpclient.c b/demo/nginx_proxy/demo-2/udpclient.c
new file mode 100644
index 0000000..76e7b05
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/udpclient.c
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#define PORT 53
+#define MAXLINE 1024
+
+// Driver code
+int
+main ()
+{
+ int sockfd;
+ char buffer[MAXLINE];
+ char *hello = "Hello from client";
+ struct sockaddr_in servaddr;
+
+ // Creating socket file descriptor
+ if ((sockfd = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
+ {
+ perror ("socket creation failed");
+ exit (EXIT_FAILURE);
+ }
+
+ memset (&servaddr, 0, sizeof (servaddr));
+
+ // Filling server information
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_port = htons (PORT);
+ servaddr.sin_addr.s_addr = inet_addr ("192.168.50.20");
+
+ int n, len;
+
+ sendto (sockfd, (const char *) hello, strlen (hello),
+ MSG_CONFIRM, (const struct sockaddr *) &servaddr,
+ sizeof (servaddr));
+ printf ("Hello message sent.\n");
+
+ n = recvfrom (sockfd, (char *) buffer, MAXLINE,
+ MSG_WAITALL, (struct sockaddr *) &servaddr, &len);
+ buffer[n] = '\0';
+ printf ("Server : %s\n", buffer);
+
+ close (sockfd);
+ return 0;
+}
diff --git a/demo/nginx_proxy/demo-2/udpserver.c b/demo/nginx_proxy/demo-2/udpserver.c
new file mode 100644
index 0000000..456c7fc
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/udpserver.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#define PORT 53
+#define MAXLINE 1024
+
+int
+main ()
+{
+ int sockfd;
+ char buffer[MAXLINE];
+ char *hello = "Hello from server";
+
+ struct sockaddr_in servaddr, cliaddr;
+ char name[128] = { 0 };
+
+ // Creating socket file descriptor
+ if ((sockfd = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
+ {
+ perror ("socket creation failed");
+ exit (EXIT_FAILURE);
+ }
+
+ memset (&servaddr, 0, sizeof (servaddr));
+ memset (&cliaddr, 0, sizeof (cliaddr));
+
+ // Filling server information
+ servaddr.sin_family = AF_INET; // IPv4
+ servaddr.sin_addr.s_addr = inet_addr ("182.167.50.30");
+ servaddr.sin_port = htons (PORT);
+
+ if (bind (sockfd, (const struct sockaddr *) &servaddr,
+ sizeof (servaddr)) < 0)
+ {
+ perror ("bind failed");
+ exit (EXIT_FAILURE);
+ }
+
+ int len, n;
+ n = recvfrom (sockfd, (char *) buffer, MAXLINE,
+ MSG_WAITALL, (struct sockaddr *) &cliaddr, &len);
+ buffer[n] = '\0';
+ (void) gethostname (name, 127);
+ printf ("Client : %s \n", buffer);
+ sendto (sockfd, (const char *) hello, strlen (hello),
+ MSG_CONFIRM, (const struct sockaddr *) &cliaddr, len);
+ printf ("%s\n", hello);
+ return 0;
+}
diff --git a/demo/nginx_proxy/demo-2/upstream_nginx.conf b/demo/nginx_proxy/demo-2/upstream_nginx.conf
new file mode 100644
index 0000000..3904197
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/upstream_nginx.conf
@@ -0,0 +1,80 @@
+#user nobody;
+worker_processes 1;
+#daemon off;
+
+#error_log logs/error.log;
+#error_log logs/error.log notice;
+#error_log logs/error.log info;
+
+#pid logs/nginx.pid;
+
+
+events {
+ worker_connections 1024;
+}
+
+
+http {
+ include 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 logs/access.log main;
+
+ sendfile on;
+ #tcp_nopush on;
+
+ #keepalive_timeout 0;
+ keepalive_timeout 65;
+
+ #gzip on;
+
+ server {
+ listen 80;
+ #server_name localhost;
+
+ #charset koi8-r;
+
+ #access_log logs/host.access.log main;
+
+ location / {
+ return 200 "Hello from upstream $hostname $server_addr:$server_port. Connect from $http_x_real_ip - $remote_user via $remote_addr:$remote_port at [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent\n";
+ }
+
+ #error_page 404 /404.html;
+
+ # redirect server error pages to the static page /50x.html
+ #
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root html;
+ }
+
+ # proxy the PHP scripts to Apache listening on 127.0.0.1:80
+ #
+ #location ~ \.php$ {
+ # proxy_pass http://127.0.0.1;
+ #}
+
+ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+ #
+ #location ~ \.php$ {
+ # root html;
+ # fastcgi_pass 127.0.0.1:9000;
+ # fastcgi_index index.php;
+ # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
+ # include fastcgi_params;
+ #}
+
+ # deny access to .htaccess files, if Apache's document root
+ # concurs with nginx's one
+ #
+ #location ~ /\.ht {
+ # deny all;
+ #}
+ }
+
+}
diff --git a/demo/nginx_proxy/demo-2/vpp_config b/demo/nginx_proxy/demo-2/vpp_config
new file mode 100644
index 0000000..aaeadfb
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/vpp_config
@@ -0,0 +1,6 @@
+set int state GigabitEthernet0/9/0 up
+set int ip addr GigabitEthernet0/9/0 172.167.50.20/24
+show version
+show version verbose
+show cpu
+show int