Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
7411ff1f
Commit
7411ff1f
authored
Oct 28, 2016
by
Alexander Alashkin
Committed by
Cesanta Bot
Oct 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop load_balancer example
PUBLISHED_FROM=d823db5e8b2831201e22bbdd3188e93bbbbbbb09
parent
f2e7facb
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1 addition
and
761 deletions
+1
-761
Makefile
examples/Makefile
+1
-1
Dockerfile
examples/load_balancer/Dockerfile
+0
-10
Makefile
examples/load_balancer/Makefile
+0
-39
README.md
examples/load_balancer/README.md
+0
-44
load_balancer.c
examples/load_balancer/load_balancer.c
+0
-646
unit_test.sh
examples/load_balancer/unit_test.sh
+0
-21
No files found.
examples/Makefile
View file @
7411ff1f
...
@@ -6,7 +6,7 @@ SUBDIRS = $(sort $(dir $(wildcard ./*/)))
...
@@ -6,7 +6,7 @@ SUBDIRS = $(sort $(dir $(wildcard ./*/)))
SUBDIRS
:=
$
(
filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./NXP_K64/ ./PIC32/ ./STM32F4_CC3100/ ./mbed/ ./nRF51/ ./nRF52/,
$(SUBDIRS)
)
SUBDIRS
:=
$
(
filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./NXP_K64/ ./PIC32/ ./STM32F4_CC3100/ ./mbed/ ./nRF51/ ./nRF52/,
$(SUBDIRS)
)
ifeq
($(OS),
Windows_NT)
ifeq
($(OS),
Windows_NT)
SUBDIRS
:=
$
(
filter-out ./
load_balancer/ ./
netcat/ ./raspberry_pi_mjpeg_led/ ./captive_dns_server/,
$(SUBDIRS)
)
SUBDIRS
:=
$
(
filter-out ./netcat/ ./raspberry_pi_mjpeg_led/ ./captive_dns_server/,
$(SUBDIRS)
)
endif
endif
.PHONY
:
$(SUBDIRS)
.PHONY
:
$(SUBDIRS)
...
...
examples/load_balancer/Dockerfile
deleted
100644 → 0
View file @
f2e7facb
FROM
cesanta/mongoose
COPY
load_balancer.c /mongoose/
WORKDIR
/mongoose
RUN
mkdir
/mongoose/certs
;
\
sed
-i
's:#include "../../mongoose.h":#include "mongoose.h":'
load_balancer.c
;
\
cc load_balancer.c mongoose.c
-o
load_balancer
-W
-Wall
-pthread
-DMG_ENABLE_SSL
-lssl
-lcrypto
EXPOSE
8000
VOLUME
["/mongoose/certs"]
ENTRYPOINT
["/mongoose/load_balancer"]
examples/load_balancer/Makefile
deleted
100644 → 0
View file @
f2e7facb
# To build with SSL under windows, do:
# wine make load_balancer.exe SSL=openssl # OpenSSL build
# wine make load_balancer.exe SSL=krypton # Krypton build
PROG
=
load_balancer
SOURCES
=
$(PROG)
.c ../../mongoose.c
CFLAGS
=
-W
-Wall
-pthread
$(CFLAGS_EXTRA)
ifeq
($(SSL),
openssl)
OPENSSL_PATH
=
./openssl-0.9.8
CFLAGS_EXTRA
+=
-DMG_ENABLE_SSL
-I
$(OPENSSL_PATH)
/include
CFLAGS_EXTRA
+=
/link /libpath:
$(OPENSSL_PATH)
/lib ssleay32.lib libeay32.lib
endif
ifeq
($(SSL),
krypton)
KRYPTON_PATH
=
../../../krypton
CFLAGS_EXTRA
+=
-DMG_ENABLE_SSL
$(KRYPTON_PATH)
/krypton.c
-I
$(KRYPTON_PATH)
endif
all
:
$(PROG)
$(PROG)
:
$(SOURCES)
$(CC)
$(SOURCES)
-o
$@
$(CFLAGS)
$(PROG).exe
:
$(SOURCES)
cl
$(SOURCES)
/I.. /MD /Fe
$@
/DMG_ENABLE_THREADS advapi32.lib
$(CFLAGS_EXTRA)
test
:
$(PROG)
$(MAKE)
-C
../api_server
sh unit_test.sh
$
$(pwd)
/
$(PROG)
docker-build
:
docker build
-t
cesanta/load_balancer .
docker-push
:
docker push cesanta/load_balancer
clean
:
rm
-rf
*
.gc
*
*
.dSYM
*
.exe
*
.obj
*
.o a.out
$(PROG)
examples/load_balancer/README.md
deleted
100644 → 0
View file @
f2e7facb
# Mongoose-based HTTP load balancer
## Configuration
Load balancer is configured with command-line flags.
### Global flags
*
`-p port`
– TCP port to listen on. Default: 8000.
*
`-l log_file`
– path to the log file. Default: none.
*
`-s ssl_cert`
– path to SSL certificate. Default: none.
### Backend configuration
Main flag is
`-b uri_prefix host_port`
– it adds a new backend for a given
URI prefix. Example:
`-b /stuff/ 127.0.0.1:8080`
will route all requests that
start with '/stuff/' to a backend at port 8080 on localhost. There is a special
syntax for
`uri_prefix`
that allows you to change the URIs that get passed to
backends:
*
`-b /stuff/=/ 127.0.0.1:8080`
– for '/stuff/thing' backend will see '/thing'.
*
`-b /stuff/=/other/ 127.0.0.1:8080`
– '/stuff/thing' => '/other/thing'.
Also there are few per-backend flags that can be placed before
`-b`
and apply
only to the next backend:
*
`-r`
– instead of proxying requests load balancer will reply with 302
redirect.
*
`-v vhost`
– match not only URI prefix but 'Host:' header as well.
### Example
```
load_balancer -s path/to/cert.pem \
-v example.com -b /site/=/ 127.0.0.1:8080 \
-b /static/ 127.0.0.1:8081 \
-b /static/ 127.0.0.1:8082
```
In this example requests to 'example.com/site/' will be forwarded to the
backend on port 8080 with '/site' prefix stripped off and requests to
'/static/' on any virtual host will be balanced in round-robin fashion between
backends on ports 8081 and 8082.
examples/load_balancer/load_balancer.c
deleted
100644 → 0
View file @
f2e7facb
This diff is collapsed.
Click to expand it.
examples/load_balancer/unit_test.sh
deleted
100644 → 0
View file @
f2e7facb
#!/bin/sh
PROG
=
$1
PORT
=
8002
cleanup
()
{
kill
-9
$PID
>
/dev/null 2>&1
}
#set -x
trap
cleanup EXIT
cleanup
$PROG
-p
$PORT
-b
/api/ 127.0.0.1:8000 &
PID
=
$!
# Perform api_server unit test through the load balancer by passing
# load balancer port to the unit test script
(
cd
../api_server
&&
make
&&
sh unit_test.sh ./api_server
$PORT
)
exit
$?
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment