Skip to content

Commit b5a32b9

Browse files
committed
Initial commit
0 parents  commit b5a32b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+9068
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: [damalis]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

README.md

Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
# [full stack proxy nginx Laravel for everyone with docker compose](https://github.com/damalis/full-stack-proxy-nginx-laravel-for-everyone-with-docker-compose)
2+
3+
If You want to build a reverse proxy website with Laravel "webapp" at short time;
4+
5+
#### Full stack Proxy Nginx Laravel "webapp":
6+
<p align="left"> <a href="https://laravel.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/958072?s=200&v=4" alt="Laravel" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.docker.com/" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/docker/docker.png" alt="docker" width="40" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://mariadb.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/5877084?s=200&v=4" alt="mariadb" height="50" width="50"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.nginx.com" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1412239?s=200&v=4" alt="nginx" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.apache.org" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/47359?s=200&v=4" alt="apache2" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.php.net" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/25158?s=200&v=4" alt="php" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://redis.io" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1529926?s=200&v=4" alt="redis" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="#" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/bash/bash.png" alt="Bash" height="50" width="50" /> </a>&nbsp;&nbsp;&nbsp;
7+
<a href="https://www.phpmyadmin.net/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1351977?s=200&v=4" alt="phpmyadmin" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://letsencrypt.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/17889013?s=200&v=4" alt="letsencrypt" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.portainer.io/?hsLang=en" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/22225832?s=200&v=4" alt="portainer" height="40" width="40"/> </a> </p>
8+
9+
Plus, manage docker containers with Portainer.
10+
11+
#### With this project you can quickly run the following:
12+
13+
- [Laravel](https://github.com/laravel) - [php-fpm](https://hub.docker.com/_/php?tab=tags&page=1&name=fpm)
14+
- [webserver (apache2/httpd)](https://hub.docker.com/_/httpd)
15+
- [proxy (nginx)](https://hub.docker.com/_/nginx)
16+
- [certbot (letsencrypt)](https://hub.docker.com/r/certbot/certbot)
17+
- [phpMyAdmin](https://hub.docker.com/r/phpmyadmin/phpmyadmin/)
18+
- [database](https://hub.docker.com/_/mariadb)
19+
- [redis](https://hub.docker.com/_/redis)
20+
- [backup](https://hub.docker.com/r/futurice/docker-volume-backup)
21+
22+
#### For certbot (letsencrypt) certificate:
23+
24+
- [Set DNS configuration of your domain name](https://support.google.com/a/answer/48090?hl=en)
25+
26+
#### IPv4/IPv6 Firewall
27+
Create rules to open ports to the internet, or to a specific IPv4 address or range.
28+
29+
- http: 80
30+
- https: 443
31+
- portainer: 9001
32+
- phpmyadmin: 9090
33+
34+
#### Contents:
35+
36+
- [Auto Configuration and Installation](#automatic)
37+
- [Requirements](#requirements)
38+
- [Manual Configuration and Installation](#manual)
39+
- [Portainer Installation](#portainer)
40+
- [Usage](#usage)
41+
42+
## Automatic
43+
44+
### Exec install shell script for auto installation and configuration
45+
46+
download with
47+
48+
```
49+
git clone https://github.com/damalis/full-stack-proxy-nginx-laravel-for-everyone-with-docker-compose.git
50+
```
51+
52+
Open a terminal and `cd` to the folder in which `docker-compose.yml` is saved and run:
53+
54+
```
55+
cd full-stack-proxy-nginx-laravel-for-everyone-with-docker-compose
56+
chmod +x install.sh
57+
./install.sh
58+
```
59+
60+
## Requirements
61+
62+
Make sure you have the latest versions of **Docker** and **Docker Compose** installed on your machine.
63+
64+
- [How install docker](https://docs.docker.com/engine/install/)
65+
- [How install docker compose](https://docs.docker.com/compose/install/)
66+
67+
Clone this repository or copy the files from this repository into a new folder. In the **docker-compose.yml** file you may change the database from MariaDB to MySQL.
68+
69+
Make sure to [add your user to the `docker` group](https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user).
70+
71+
## Manual
72+
73+
### Configuration
74+
75+
download with
76+
```
77+
git clone https://github.com/damalis/full-stack-proxy-nginx-laravel-for-everyone-with-docker-compose.git
78+
```
79+
80+
Open a terminal and `cd` to the folder in which `docker-compose.yml` is saved and run:
81+
82+
```
83+
cd full-stack-proxy-nginx-laravel-for-everyone-with-docker-compose
84+
```
85+
86+
Copy the example environment into `.env`
87+
88+
```
89+
cp env.example .env
90+
```
91+
92+
Edit the `.env` file to change values of ```LOCAL_TIMEZONE```, ```DOMAIN_NAME```, ```DIRECTORY_PATH```, ```LETSENCRYPT_EMAIL```, ```DB_USER```, ```DB_PASSWORD```, ```DB_NAME```, ```MYSQL_ROOT_PASSWORD```, ```PMA_CONTROLUSER```, ```PMA_CONTROLPASS```, ```PMA_HTPASSWD_USERNAME``` and ```PMA_HTPASSWD_PASSWORD```.
93+
94+
LOCAL_TIMEZONE=[to see local timezones](https://docs.diladele.com/docker/timezones.html)
95+
96+
DIRECTORY_PATH=```pwd``` at command line
97+
98+
and
99+
100+
```
101+
cp ./phpmyadmin/apache2/sites-available/default-ssl.sample.conf ./phpmyadmin/apache2/sites-available/default-ssl.conf
102+
```
103+
104+
change example.com to your domain name in ```./phpmyadmin/apache2/sites-available/default-ssl.conf``` file.
105+
106+
### Installation
107+
108+
Firstly: will create external volume
109+
110+
```
111+
docker volume create --driver local --opt type=none --opt device=${DIRECTORY_PATH}/certbot --opt o=bind certbot-etc
112+
```
113+
114+
```
115+
docker-compose up -d
116+
```
117+
118+
then reloading for proxy ssl configuration
119+
120+
```
121+
docker container restart proxy
122+
```
123+
124+
The containers are now built and running. You should be able to access the Laravel installation with the configured IP in the browser address. `https://example.com`.
125+
126+
For convenience you may add a new entry into your hosts file.
127+
128+
## Portainer
129+
130+
```
131+
docker volume create portainer_data
132+
docker-compose -f portainer-docker-compose.yml -p portainer up -d
133+
```
134+
135+
manage docker with [Portainer](https://www.portainer.io/solutions/docker) is the definitive container management tool for Docker, Docker Swarm with it's highly intuitive GUI and API.
136+
137+
You can also visit `https://example.com:9001` to access portainer after starting the containers.
138+
139+
## Usage
140+
141+
#### You could manage docker containers without command line with portainer.
142+
143+
### Show both running and stopped containers
144+
145+
The docker ps command only shows running containers by default. To see all containers, use the -a (or --all) flag:
146+
147+
```
148+
docker ps -a
149+
```
150+
151+
### Starting containers
152+
153+
You can start the containers with the `up` command in daemon mode (by adding `-d` as an argument) or by using the `start` command:
154+
155+
```
156+
docker-compose start
157+
```
158+
159+
### Stopping containers
160+
161+
```
162+
docker-compose stop
163+
```
164+
165+
### Removing containers
166+
167+
To stop and remove all the containers use the `down` command:
168+
169+
```
170+
docker-compose down
171+
```
172+
173+
to remove portainer and the other containers
174+
```
175+
docker rm -f $(docker ps -a -q)
176+
```
177+
178+
Use `-v` if you need to remove the database volume which is used to persist the database:
179+
180+
```
181+
docker-compose down -v
182+
```
183+
184+
to remove external certbot-etc and portainer and the other volumes
185+
186+
```
187+
docker volume rm $(docker volume ls -q)
188+
```
189+
190+
### Project from existing source
191+
192+
Copy all files into a new directory:
193+
194+
You can now use the `up` command:
195+
196+
```
197+
docker-compose up -d
198+
```
199+
200+
#### Docker run reference
201+
202+
[https://docs.docker.com/engine/reference/run/](https://docs.docker.com/engine/reference/run/)
203+
204+
### Website
205+
206+
You should see the "Laravel" page in your browser. If not, please check if your PHP installation satisfies Laravel's requirements.
207+
208+
```
209+
https://example.com
210+
```
211+
212+
add or remove code in the ```./php-fpm/php/conf.d/security.ini``` file for custom php.ini configurations
213+
214+
[https://www.php.net/manual/en/configuration.file.php](https://www.php.net/manual/en/configuration.file.php)
215+
216+
add or remove code in the ```./php-fpm/php-fpm.d/z-www.conf``` file for php-fpm configurations
217+
218+
Or you should make changes custom host configurations then must restart service
219+
220+
```
221+
docker container restart laravel
222+
```
223+
224+
FPM uses php.ini syntax for its configuration file - php-fpm.conf, and pool configuration files.
225+
226+
[https://www.php.net/manual/en/install.fpm.configuration.php](https://www.php.net/manual/en/install.fpm.configuration.php)
227+
228+
add and/or remove laravel site folders and files with any ftp client program in ```./laravel/webapp``` folder.
229+
<br />You can also visit `https://example.com` to access website after starting the containers.
230+
231+
#### Proxy
232+
233+
Proxying is typically used to distribute the load among several servers, seamlessly show content from different websites, or pass requests for processing to application servers over protocols other than HTTP.
234+
235+
[https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/](https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/)
236+
237+
#### Webserver
238+
239+
add or remove code in the ```./webserver/extra/httpd-vhosts.conf``` file for custom apache2/httpd configurations
240+
241+
[https://httpd.apache.org/docs/2.4/en/configuring.html](https://httpd.apache.org/docs/2.4/en/configuring.html)
242+
243+
#### Database
244+
245+
The configuration for Laravel's database services is located in your application's config/database.php configuration file.
246+
247+
Database host = database
248+
249+
[https://laravel.com/docs/9.x/database](https://laravel.com/docs/9.x/database)
250+
251+
[https://mariadb.com/kb/en/configuring-mariadb-with-option-files/](https://mariadb.com/kb/en/configuring-mariadb-with-option-files/)
252+
253+
#### Redis and Cache
254+
255+
You may configure your application's Redis settings via the config/database.php configuration file.
256+
257+
Redis host = redis
258+
259+
Redis host port = 6379
260+
261+
[https://laravel.com/docs/9.x/redis](https://laravel.com/docs/9.x/redis)
262+
263+
Your application's cache configuration file is located at config/cache.php.
264+
265+
[https://laravel.com/docs/9.x/cache#main-content](https://laravel.com/docs/9.x/cache#main-content)
266+
267+
### phpMyAdmin
268+
269+
You can add your own custom config.inc.php settings (such as Configuration Storage setup) by creating a file named config.user.inc.php with the various user defined settings in it, and then linking it into the container using:
270+
271+
```
272+
./phpmyadmin/config.user.inc.php
273+
```
274+
275+
You can also visit `https://example.com:9090` to access phpMyAdmin after starting the containers.
276+
277+
The first authorize screen(htpasswd;username or password) and phpmyadmin login screen the username and the password is the same as supplied in the `.env` file.
278+
279+
### backup
280+
281+
This will back up the all files and folders, once per day, and write it to ./backups with a filename like backup-2022-02-07T16-51-56.tar.gz
282+
283+
#### example for crontab file on the host machine
284+
285+
##### # old docker backup folder remove
286+
287+
```
288+
50 23 * * * find ${DIRECTORY_PATH}/backups/backup* -type f -mtime +1 | xargs rm
289+
```
290+
291+
##### # backup exclude laravel, backups folders in ${DIRECTORY_PATH}
292+
293+
```
294+
00 01 * * * tar -czvf ${DIRECTORY_PATH}/backups/'backup-example.com-'$(date +"\%Y-\%m-\%dT\%H-\%M-\%S")'.tar.gz' --exclude='backups' ${DIRECTORY_PATH}
295+
```
296+
297+
[CronHowto](https://help.ubuntu.com/community/CronHowto)

backups/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore

certbot/.certbot.lock

Whitespace-only changes.

certbot/ssl-dhparam.pem

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-----BEGIN DH PARAMETERS-----
2+
MIIBCAKCAQEA3T1FEu1mdoEgqUL/v7OPEGd8yp+/2nUHyRFeyx9UQu7GXWMk7SSC
3+
ob/WE62HKtTiL3GskWJYh5HCPcBOETCWtbeib4xX4x/M7fzRU+io7hraIXPq3f1/
4+
/9KMljeQF8YqX913DU0WbeA8gJrpWEKSTiYkKBoS5K0AfgQDcDv+rHD8vOANfU/h
5+
YtR/Pjidl8TL/64fyWnGLn1l6VMzyYqgxGIlVX51fdwkO1KPpI+nLvURv7iXph3H
6+
WdpZl7wT1kcctjqH84MFBb4CotzUceY/+L3JOtUMkQbf68nB6Fwrx63+9IEYN9of
7+
0pyDWBhM9NbnJUHZsJEBq49T4FPlMJCiMwIBAg==
8+
-----END DH PARAMETERS-----

database/conf.d/z-mysql.cnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[mysql]

0 commit comments

Comments
 (0)