Skip to content

Commit 5e8e256

Browse files
committed
Initial import!
1 parent 2ff0173 commit 5e8e256

File tree

5 files changed

+130
-1
lines changed

5 files changed

+130
-1
lines changed

.gitignore

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

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM nginx:alpine
2+
LABEL "com.example.vendor"="Neontribe"
3+
LABEL version="1.0"
4+
LABEL description="Nginx alpine image built to reverse proxy requests to a PHP FPM server"
5+
6+
ADD nginx_default.conf /etc/nginx/conf.d/default.conf
7+
8+
ENV PORT=80
9+
ENV SEVER_NAME=nginx.local
10+
ENV FPM_TARGET=kimai:9000
11+
ENV SERVER_ROOT=/opt/kimai
12+
13+
# docker build --rm -t tobybatch/nginx-fpm-reverse-proxy .

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,43 @@
1-
# nginx-fpm-reverse-proxy
1+
# nginx-fpm-reverse-proxy
2+
3+
A simple reverse proxy to forward requests on to a PHP FPM Server.
4+
5+
Built for use in the Kimai project it can be used for any PHP FPM server.
6+
7+
## Quickstart
8+
9+
docker run \
10+
-ti \
11+
--rm \
12+
-name nginx-fpm-reverse-proxy \
13+
-v ${pwd}:/opt/kimai \
14+
-p 8001:80 \
15+
tobybatch/nginx-fpm-reverse-proxy
16+
17+
## Building
18+
19+
There is no build time customisation:
20+
21+
docker build .
22+
23+
## Environment varaibles
24+
25+
* `PORT=80`
26+
27+
Which port the nginx server should listen on. It will also need to be set at with `-p $PORT:80` at run time.
28+
29+
* `SEVER_NAME=nginx.local`
30+
31+
The server name directive used by the nginx server
32+
33+
* `FPM_TARGET=kimai:9000`
34+
35+
Where the PHP FPM server is
36+
37+
* `SERVER_ROOT=/opt/kimai`
38+
39+
What to use as the document root, We need this to be set (as read only) so that nginx can server static files.
40+
41+
### Docker compose
42+
43+
See [docker-compose.yml](./docker-compose.yml)

docker-compose.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: '3.5'
2+
services:
3+
4+
# THIS RUNS A LOCAL NGINX PROXY TO A LOCAL KIMAI RUNNING IN DEV MODE
5+
6+
nginx:
7+
image: tobybatch/nginx-fpm-reverse-proxy
8+
ports:
9+
- 8001:80
10+
volumes:
11+
- public:/opt/kimai/public:ro
12+
restart: unless-stopped
13+
depends_on:
14+
- kimai
15+
16+
kimai:
17+
image: kimai/kimai2:fpm-latest-dev
18+
environment:
19+
- DATABASE_URL=mysql://kimaiuser:kimaipassword@sqldb/kimai
20+
volumes:
21+
- public:/opt/kimai/public
22+
restart: unless-stopped
23+
24+
# Needed for Kimai
25+
sqldb:
26+
image: mariadb
27+
environment:
28+
- MYSQL_DATABASE=kimai
29+
- MYSQL_USER=kimaiuser
30+
- MYSQL_PASSWORD=kimaipassword
31+
- MYSQL_ROOT_PASSWORD=changemeplease
32+
volumes:
33+
- /var/lib/mysql
34+
command: --default-storage-engine innodb
35+
restart: unless-stopped
36+
37+
volumes:
38+
public:
39+
sqldb:

nginx_default.conf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
server {
2+
listen ${PORT};
3+
index index.php;
4+
server_name ${SEVER_NAME};
5+
root ${SERVER_ROOT};
6+
7+
# cache static asset files
8+
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
9+
expires max;
10+
log_not_found off;
11+
}
12+
13+
# for health checks
14+
location /health {
15+
return 200 'alive';
16+
add_header Content-Type text/plain;
17+
}
18+
19+
location / {
20+
try_files $uri $uri/ /index.php$is_args$args;
21+
}
22+
23+
location ~ ^/index\.php(/|$) {
24+
fastcgi_pass ${FPM_TARGET};
25+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
26+
include fastcgi_params;
27+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
28+
fastcgi_param DOCUMENT_ROOT $realpath_root;
29+
internal;
30+
}
31+
}
32+
33+
# mkdir -p .vim/syntax && wget -O .vim/syntax/nginx.vim http://www.vim.org/scripts/download_script.php\?src_id\=19394
34+
# vim: set syntax=nginx ft=nginx:

0 commit comments

Comments
 (0)