Skip to content
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

Version bumped, Hide Server Info, Execute Permission & Few cd checks #10

Open
wants to merge 3 commits into
base: http2
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ nginx-portable
==============

nginx-portable is a portable version of the nginx web server for linux.
At this point in time the package contains nginx-1.10.2 or nginx-1.11.8 with the --latest flag; so no fastcgi and mysql just yet.
At this point in time the package contains nginx-1.16.1 or nginx-1.17.9 with the --latest flag; so no fastcgi and mysql just yet.

#### About nginx

Expand Down
31 changes: 21 additions & 10 deletions compile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

BASEDIR=$(cd "$(dirname "$0")"; pwd)
BASEDIR=$(cd "$(dirname "$0")" || exit; pwd)
TMPDIR=tmp
[[ "$1" == "--latest" ]] && NGINXV=nginx-1.11.8 || NGINXV=nginx-1.10.2
echo "nginx version "$NGINXV" selected"
[[ "$1" == "--latest" ]] && NGINXV=nginx-1.21.1 || NGINXV=nginx-1.20.1
echo "nginx version $NGINXV selected"
NGINXDIR=$NGINXV/

# Create and move into the tmp dirctory
mkdir -p $TMPDIR
cd $TMPDIR
cd $TMPDIR || { echo "Failure to cd tmp dir"; exit 1; }

# Download nginx source

Expand All @@ -29,7 +29,13 @@ fi
echo "Extracting file."
tar zxf ./$NGINXV.tar.gz

cd ./$NGINXDIR
cd ./$NGINXDIR || { echo "Failure to cd nginx dir"; exit 1; }

# Security : Hide Server Information
sed -i 's@"nginx/"@"-/"@g' src/core/nginx.h
sed -i 's@r->headers_out.server == NULL@0@g' src/http/ngx_http_header_filter_module.c
sed -i 's@r->headers_out.server == NULL@0@g' src/http/v2/ngx_http_v2_filter_module.c
sed -i 's@<hr><center>nginx</center>@@g' src/http/ngx_http_special_response.c

# Configure and make
echo "Configuring executable."
Expand All @@ -39,14 +45,19 @@ echo "Building executable."
make >> ../../logs/compile.log

# Move bin file into appropriate dir
if [ ! -d $BASEDIR/bin/ ]; then
mkdir $BASEDIR/bin
if [ ! -d "$BASEDIR"/bin/ ]; then
mkdir "$BASEDIR"/bin
fi

cp -f objs/nginx $BASEDIR/bin/
cp -f objs/nginx "$BASEDIR"/bin/

# Permission to run script & nginx bin
chmod a+x nginx-portable
chmod a+x bin/nginx

cd "$BASEDIR" || { echo "Failure to cd basedir"; exit 1; }

cd $BASEDIR

# Remove the temporary directory
echo "Cleaning up."
rm -r $TMPDIR/$NGINXV && rm -r $TMPDIR/$NGINXV.tar.gz
rm -r ${TMPDIR:?}/$NGINXV && rm -r ${TMPDIR:?}/$NGINXV.tar.gz