Skip to content

Commit

Permalink
upgraded all nginx config files and shell script.
Browse files Browse the repository at this point in the history
and other shell sciprt file also upgraded.

to get more high performance for web-server, config modified
removed cache option in proxy config file
normal case in proxy, it doesn't need.
will support cache server next version.

all shell script upgraded for readable getting data by keyboard input type.

and some shell script files added to support create some config file.
  • Loading branch information
bluebamus committed Jun 23, 2020
1 parent f247e3e commit c58d839
Show file tree
Hide file tree
Showing 17 changed files with 525 additions and 270 deletions.
24 changes: 20 additions & 4 deletions config/app-server/php/php_conf.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
#!/bin/bash

account=$1
port=$2
while :
do
echo -n "Enter the service domain >"
read domain
echo "Entered service domain: $domain"
if [[ "$domain" != "" ]]; then
break
fi
done

while :
do
echo -n "Enter the service portnumber >"
read portnumber
echo "Entered service portnumber: $portnumber"
if [[ "$portnumber" != "" ]]; then
break
fi
done

sed 's/account/'$account'/' sample_php.conf > $account'1'.temp
sed 's/port/'$port'/' $account'1'.temp > ./pool.d/$account'_php'.conf
sed 's/domain/'$domain'/' sample_php.conf > $domain'1'.temp
sed 's/portnumber/'$portnumber'/' $domain'1'.temp > ./pool.d/$domain'_php'.conf

rm *.temp
4 changes: 2 additions & 2 deletions config/app-server/php/sample_php.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[account]
[domain]

user = www-data
group = www-data

listen = [::]:port
listen = [::]:portnumber

;listen.owner = www-data
;listen.group = www-data
Expand Down
75 changes: 64 additions & 11 deletions config/web-server/nginx/gunicorn/nginx_conf.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,68 @@
#!/bin/bash

account=$1
domain=$2
portnumber=$3
appname=$4
service_port=$5

sed 's/account/'$account'/' sample_nginx.conf > $account'1'.temp
sed 's/domain/'$domain'/g' $account'1'.temp > $account'2'.temp
sed 's/portnumber;/'$portnumber';/' $account'2'.temp > $account'3'.temp
sed 's/appname/'$appname'/' $account'3'.temp > $account'4'.temp
sed 's/service_port/'$service_port'/' $account'4'.temp > ./pool.d/$account'_gunicorn_ng'.conf
while :
do
echo -n "Enter the service web root >"
read webroot
echo "Entered service web root: $webroot"
if [[ "$webroot" != "" ]]; then
break
fi
done

while :
do
echo -n "Enter the service portnumber >"
read portnumber
echo "Entered service portnumber: $portnumber"
if [[ "$portnumber" != "" ]]; then
break
fi
done

while :
do
echo -n "Enter the service domain >"
read domain
echo "Entered service domain: $domain"
if [[ "$domain" != "" ]]; then
break
fi
done

while :
do
echo -n "Enter the app name >"
read appname
echo "Entered app name: $appname"
if [[ "$appname" != "" ]]; then
break
fi
done

echo "Enter the serviceport"
echo -n "if you push enter with none, there are no port number >"
read serviceport
echo "Entered proxy port: $serviceport"

while :
do
echo -n "Enter the file name >"
read filename
echo "Entered file name: $filename"
if [[ "$filename" != "" ]]; then
break
fi
done

sed 's/webroot/'$webroot'/g' sample_nginx.conf > $filename'1'.temp
sed 's/portnumber/'$portnumber'/g' $filename'1'.temp > $filename'2'.temp
sed 's/domain/'$domain'/g' $filename'2'.temp > $filename'3'.temp
sed 's/appname/'$appname'/g' $filename'3'.temp > $filename'4'.temp
if [[ "$serviceport" == "" ]]; then
sed 's/:serviceport/''/g' $filename'4'.temp > $filename'5'.temp
else
sed 's/serviceport/'$serviceport'/g' $filename'4'.temp > $filename'5'.temp
sed 's/filename/'$filename'/g' $filename'5'.temp > ./pool.d/$filename'_gunicorn_ng'.conf

rm *.temp
75 changes: 64 additions & 11 deletions config/web-server/nginx/gunicorn/nginx_https_conf.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,68 @@
#!/bin/bash

account=$1
domain=$2
portnumber=$3
appname=$4
service_port=$5

sed 's/account/'$account'/' sample_nginx_https.conf > $account'1'.temp
sed 's/domain/'$domain'/g' $account'1'.temp > $account'2'.temp
sed 's/portnumber;/'$portnumber';/' $account'2'.temp > $account'3'.temp
sed 's/appname/'$appname'/' $account'3'.temp > $account'4'.temp
sed 's/service_port/'$service_port'/' $account'4'.temp > ./pool.d/$account'_gunicorn_https_ng'.conf
while :
do
echo -n "Enter the service web root >"
read webroot
echo "Entered service web root: $webroot"
if [[ "$webroot" != "" ]]; then
break
fi
done

while :
do
echo -n "Enter the service portnumber >"
read portnumber
echo "Entered service portnumber: $portnumber"
if [[ "$portnumber" != "" ]]; then
break
fi
done

while :
do
echo -n "Enter the service domain >"
read domain
echo "Entered service domain: $domain"
if [[ "$domain" != "" ]]; then
break
fi
done

while :
do
echo -n "Enter the app name >"
read appname
echo "Entered app name: $appname"
if [[ "$appname" != "" ]]; then
break
fi
done

echo "Enter the serviceport"
echo -n "if you push enter with none, there are no port number >"
read serviceport
echo "Entered proxy port: $serviceport"

while :
do
echo -n "Enter the file name >"
read filename
echo "Entered file name: $filename"
if [[ "$filename" != "" ]]; then
break
fi
done

sed 's/webroot/'$webroot'/g' sample_nginx_https.conf > $filename'1'.temp
sed 's/portnumber/'$portnumber'/g' $filename'1'.temp > $filename'2'.temp
sed 's/domain/'$domain'/g' $filename'2'.temp > $filename'3'.temp
sed 's/appname/'$appname'/g' $filename'3'.temp > $filename'4'.temp
if [[ "$serviceport" == "" ]]; then
sed 's/:serviceport/''/g' $filename'4'.temp > $filename'5'.temp
else
sed 's/serviceport/'$serviceport'/g' $filename'4'.temp > $filename'5'.temp
sed 's/filename/'$filename'/g' $filename'5'.temp > ./pool.d/$filename'_gunicorn_https_ng'.conf

rm *.temp
84 changes: 0 additions & 84 deletions config/web-server/nginx/gunicorn/pool.d/sample_php_ng.conf

This file was deleted.

29 changes: 23 additions & 6 deletions config/web-server/nginx/gunicorn/sample_nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,57 @@ server {

server_tokens off;

# add_header Strict-Transport-Security "max-age=31536000";
# add_header Strict-Transport-Security "max-age=31536000" always;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
# your certs, I'm using let's encrypt domain wildcards.

add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";

charset utf-8;

resolver 8.8.8.8 8.8.4.4 valid=300s; # resolver $DNS-IP-1 $DNS-IP-2 valid=300s;
resolver_timeout 5s;

#set same size as post_max_size(php.ini or php_admin_value).
client_max_body_size 20M;

access_log /log/account.com.access.log main;
error_log /log/account.com.error.log warn;
access_log /log/filename.com.access.log main;
error_log /log/filename.com.error.log warn;

# Django media
location /media {
internal;
gzip_static on;
expires max;
alias /www/py37/django_test/repo/media; # your Django project's media files - amend as required
alias /www/py37/django_test/repo/media;
#alias webroot/media; # your Django project's media files - amend as required
include /etc/nginx/mime.types;
}

location /static {
gzip_static on;
expires max;
alias /www/py37/django_test/repo/.static_root; # your Django project's static files - amend as required
alias /www/py37/django_test/repo/.static_root;
#alias webroot/.static_root; # your Django project's static files - amend as required
include /etc/nginx/mime.types;
}

location / {
proxy_set_header Host $http_host;
proxy_buffering off;
#client_max_body_size 2000m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http:/appname:service_port;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://appname:serviceport;
proxy_redirect http:// https://;
proxy_read_timeout 90;
}

# Allow Lets Encrypt Domain Validation Program
Expand Down
Loading

0 comments on commit c58d839

Please sign in to comment.