collective / collective/training-deploy-project

Enhancement: Ngnix Templates

Open
#11 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Makefile
Stars
6
Forks
22
PR merge metrics
No merged PRs in 30d

Description

Newer version Nginix (1.9 or later) allow use of variable substitution using [nginux templates](https://github.com/docker-library/docs/tree/master/nginx#using-environment-variables-in-nginx-configuration)

### Docker-compose web service
```
webserver:
image: nginx:latest
volumes:
- ./files/nginx/templates:/etc/nginx/templates
depends_on:
- backend
- frontend
ports:
- "80:80"
environment:
- NGINX_HOST=example.com

```
### Nginx Template
/files/nginx/templates/default.conf.template

```
upstream backend {
server backend:8080;
}
upstream frontend {
server frontend:3000;
}

server {
listen 80 default_server;
server_name ${NGINX_HOST};

location ~ /\+\+api\+\+($|/.*) {
rewrite ^/\+\+api\+\+($|/.*) /VirtualHostBase/http/$server_name/Plone/++api++/VirtualHostRoot/$1 break;
proxy_pass http://backend;
}

location ~ / {
location ~* \.(js|jsx|css|less|swf|eot|ttf|otf|woff|woff2)$ {
add_header Cache-Control "public";
expires +1y;
proxy_pass http://frontend;
}
location ~* static.*\.(ico|jpg|jpeg|png|gif|svg)$ {
add_header Cache-Control "public";
expires +1y;
proxy_pass http://frontend;
}

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_redirect http:// https://;
proxy_pass http://frontend;
}
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Docker-compose web service and the specified /files/nginx/templates/default.conf.template path. Use the linked Nginx documentation to check the expected variable-substitution setup; done means the service mounts the template and NGINX_HOST supplies server_name.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker-compose, nginx
Domain
devops, infrastructure
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.