Skip to content

Make it built #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 18 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,109 +23,36 @@ To compile nginx with this module, use an `--add-module` option to `configure`
./configure --add-module=path/to/this/module/directory
```

# All commands
Here's a list of all of the commands I used on a fresh CentOS VM to get this up and running
# Full ubuntu install example

```
yum update
yum -y groupinstall 'Development Tools'
yum -y install unzip zip gunzip wget httpd-devel pcre perl pcre-devel zlib zlib-devel GeoIP GeoIP-devel openssl openssl-devel cmake git
cd
mkdir dl
cd dl
wget https://github.com/akheron/jansson/archive/2.8.zip
unzip 2.8.zip
ln -sf jansson-2.8 jansson
cd jansson
cmake .
make
make install
cd ~/dl
wget https://github.com/benmcollins/libjwt/archive/master.zip
unzip master.zip
ln -sf libjwt-master libjwt
cd libjwt
```

To compile libjwt on my mac I had to edit the `CMakeLists.txt` file and add this line at the top:

```
include_directories(/usr/local/Cellar/openssl/1.0.2h_1/include/)
```

To compile libjwt on my CentOS VM I had to edit the `CMakeLists.txt` file and add this flag to the list of `CMAKE_C_FLAGS`:
apt-get -y install curl wget git-core build-essential libjansson-dev libssl-dev libsslcommon2-dev libpcre3-dev software-properties-common openssl libjansson-dev autoconf libgeoip-dev

```
-std=gnu99
```
more commands...

```
vi include/jwt.h
vi libjwt/jwt.c
vi CMakeLists.txt
cmake .
make jwt_static

cd ~/dl
git clone https://github.com/TeslaGov/ngx-http-auth-jwt-module

cd ~/dl
wget http://nginx.org/download/nginx-1.10.1.tar.gz
tar -xzf nginx-1.10.1.tar.gz
ln -sf nginx-1.10.1 nginx
cd nginx
```

You may need to change this configure line to support your needs
git clone https://github.com/benmcollins/libjwt
cd libjwt
autoreconf -i
./configure --prefix=/usr --mandir=\${prefix}/share/man --infodir=\${prefix}/share/info
make all
make install

```
./configure
--user=nginx \
--group=nginx \
curl -s http://nginx.org/download/nginx-1.11.10.tar.gz | tar -zxf -
git clone https://github.com/freman/ngx-http-auth-jwt-module
cd nginx-1.11.10
./configure \
--user=www-data \
--group=www-data \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_addition_module \
--with-http_geoip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--add-module=/root/dl/ngx-http-auth-jwt-module/src
```

At this point I needed to edit the Makefile. I couldn't figure out how to link in the dependent libraries via the configure command so I added them in by hand.

I appended this to my CLFAGS line:

```
-I /root/dl/libjwt/include -I /root/dl/jansson/src -std=gnu99
```

I added these lines to objs/nginx list:

```
objs/addon/ngx_http_auth_jwt_module/ngx_http_auth_jwt_module.o \
/root/dl/libjwt/lib/libjwt.a \
/usr/local/lib/libjansson.a
```

I added these lines to the link command:

```
objs/addon/ngx_http_auth_jwt_module/ngx_http_auth_jwt_module.o \
-L /root/dl/libjwt/lib \
-L /usr/local/lib \
-ldl -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lz -ljwt -ljansson \
-Wl,-E
```

```
vi Makefile
make
make install
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
```
--add-module=../ngx-http-auth-jwt-module
```
14 changes: 14 additions & 0 deletions config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ngx_addon_name=ngx_http_auth_jwt_module

if test -n "$ngx_module_link"; then
ngx_module_type=HTTP
ngx_module_name=ngx_http_auth_jwt_module
ngx_module_srcs="$ngx_addon_dir/src/ngx_http_auth_jwt_module.c"
ngx_module_libs="-ljwt -ljansson"

. auto/module
else
HTTP_MODULES="$HTTP_MODULES ngx_http_auth_jwt_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_http_auth_jwt_module.c"
CORE_LIBS="$CORE_LIBS -ljwt -ljansson"
fi