-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb4b338
commit 45a0cca
Showing
5 changed files
with
99 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,52 @@ | ||
# Wildcard laravel nginx letsencrypt configurations | ||
# Configurations: secure laravel + wildcard nginx + wildcard letsencrypt https | ||
|
||
This script allows you to quickly deploy the latest version of nginx web server, configure wildcard domain routing, install a secure ssl wildcard certificate through letsencrypt. This installation has been tested on **ubuntu 16.04** and **nginx 1.15.11**. | ||
|
||
Based on [Nginx Server Configs](https://github.com/h5bp/server-configs-nginx). | ||
|
||
## Installation | ||
|
||
Tested on | ||
### 0. Install nginx latest version [optional] | ||
|
||
```bash | ||
nginx -v | ||
|
||
# nginx version: nginx/1.15.8 | ||
./bin/install-nginx.sh | ||
``` | ||
|
||
### Wildcard | ||
### 0. Install docker [optional] | ||
|
||
```bash | ||
sudo mkdir /etc/nginx/server-configs-nginx && sudo chown $(whoami) /etc/nginx/server-configs-nginx | ||
git clone https://github.com/h5bp/server-configs-nginx.git /etc/nginx/server-configs-nginx | ||
./bin/install-docker.sh | ||
``` | ||
|
||
sudo mkdir /etc/nginx/base && sudo chown $(whoami) /etc/nginx/base | ||
git clone https://github.com/isswp101/laravel-nginx-configs.git /etc/nginx/base | ||
### 1. Install nginx configurations | ||
|
||
```bash | ||
./bin/install-configurations.sh <base_domain_name> | ||
``` | ||
|
||
sudo cp /etc/nginx/base/nginx/nginx.conf /etc/nginx/nginx.conf | ||
sudo cp /etc/nginx/base/nginx/conf.d/wildcard.conf /etc/nginx/conf.d/wildcard.conf | ||
The following files will be created: | ||
|
||
sudo systemctl reload nginx | ||
``` | ||
/etc/nginx | ||
|- server-configs-nginx // base configurations from h5bp | ||
|- base // bash nginx configurations | ||
|- conf.d | ||
| - default.conf | ||
| - wildcard.conf | ||
|- nginx.conf | ||
``` | ||
|
||
### SSL | ||
### 2. Install wildcard ssl certificates using letsencrypt | ||
|
||
```bash | ||
./certbot/certonly.sh | ||
sudo wget https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/options-ssl-nginx.conf -P /etc/letsencrypt | ||
sudo openssl dhparam -out /etc/letsencrypt/ssl-dhparams.pem 2048 | ||
sudo systemctl reload nginx | ||
./bin/install-ssl.sh <base_domain_name> | ||
``` | ||
|
||
The following files will be created: | ||
|
||
``` | ||
/etc/letsencrypt | ||
|- live | ||
|- options-ssl-nginx.conf | ||
|- ssl-dhparams.pem | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
if [ "$1" = "" ] | ||
then | ||
echo "Usage: $0 <base_domain_name>" | ||
exit 1 | ||
fi | ||
|
||
# Clone h5bp | ||
sudo mkdir /etc/nginx/server-configs-nginx && sudo chown $(whoami) /etc/nginx/server-configs-nginx | ||
git clone https://github.com/h5bp/server-configs-nginx.git /etc/nginx/server-configs-nginx | ||
|
||
# Clone base configurations | ||
sudo mkdir /etc/nginx/base && sudo chown $(whoami) /etc/nginx/base | ||
git clone https://github.com/devemio/laravel-nginx-configs.git /etc/nginx/base | ||
|
||
# Install default and wildcard domain configurations | ||
sudo cp /etc/nginx/base/nginx/nginx.conf /etc/nginx/nginx.conf | ||
sudo cp /etc/nginx/base/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf | ||
sudo cp /etc/nginx/base/nginx/conf.d/wildcard.conf /etc/nginx/conf.d/wildcard.conf | ||
|
||
# Replace path to ssl certificates | ||
sed -i "s|/etc/letsencrypt/live/example.com|/etc/letsencrypt/live/$1|g" /etc/nginx/conf.d/default.conf | ||
sed -i "s|/etc/letsencrypt/live/example.com|/etc/letsencrypt/live/$1|g" /etc/nginx/conf.d/wildcard.conf | ||
|
||
# Restart nginx | ||
sudo systemctl reload nginx | ||
|
||
# Install base html page | ||
sudo cp /etc/nginx/base/html/404.html /var/www/html/index.html | ||
sudo chown $(whoami) /var/www/html/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
sudo sh -c "echo 'deb http://nginx.org/packages/mainline/ubuntu/ '$(lsb_release -cs)' nginx' > /etc/apt/sources.list.d/nginx.list" | ||
sudo sh -c "echo 'deb-src http://nginx.org/packages/mainline/ubuntu/ '$(lsb_release -cs)' nginx' >> /etc/apt/sources.list.d/nginx.list" | ||
|
||
wget https://nginx.org/keys/nginx_signing.key -O - | sudo apt-key add - | ||
|
||
sudo apt update | ||
sudo apt install nginx | ||
|
||
sudo systemctl start nginx | ||
sudo systemctl status nginx | ||
|
||
sudo ufw allow https comment 'nginx' | ||
sudo ufw allow http comment 'nginx' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
if [ "$1" = "" ] | ||
then | ||
echo "Usage: $0 <base_domain_name>" | ||
exit 1 | ||
fi | ||
|
||
sudo ./certbot/certonly.sh $1 | ||
sudo wget https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/options-ssl-nginx.conf -P /etc/letsencrypt | ||
sudo openssl dhparam -out /etc/letsencrypt/ssl-dhparams.pem 2048 | ||
sudo systemctl reload nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters