This commit is contained in:
13
gateway/Dockerfile-docker
Normal file
13
gateway/Dockerfile-docker
Normal file
@@ -0,0 +1,13 @@
|
||||
ARG IMAGENAME
|
||||
|
||||
FROM ${IMAGENAME}
|
||||
|
||||
ENV DOMAIN_NAME=default
|
||||
|
||||
EXPOSE 80 443
|
||||
|
||||
COPY ./ssl.conf.template /etc/nginx/conf.d/ssl.conf.template
|
||||
|
||||
VOLUME ["/etc/nginx/conf.d/cert/"]
|
||||
|
||||
CMD /bin/sh -c "envsubst '\$DOMAIN_NAME' < /etc/nginx/conf.d/ssl.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
|
11
gateway/Dockerfile-kubernetes
Normal file
11
gateway/Dockerfile-kubernetes
Normal file
@@ -0,0 +1,11 @@
|
||||
ARG IMAGENAME
|
||||
|
||||
FROM ${IMAGENAME}
|
||||
|
||||
ENV DOMAIN_NAME=default
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
COPY ./default.conf.template /etc/nginx/conf.d/default.conf.template
|
||||
|
||||
CMD /bin/sh -c "envsubst '\$localhost' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
|
16
gateway/default.conf.template
Normal file
16
gateway/default.conf.template
Normal file
@@ -0,0 +1,16 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name ${DOMAIN_NAME};
|
||||
|
||||
location / {
|
||||
proxy_pass http://blog:4000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
location /twikoo {
|
||||
proxy_pass http://blog-twikoo:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
32
gateway/ssl.conf.template
Normal file
32
gateway/ssl.conf.template
Normal file
@@ -0,0 +1,32 @@
|
||||
server{
|
||||
listen 80;
|
||||
|
||||
server_name ${DOMAIN_NAME};
|
||||
|
||||
#(第一种)把http的域名请求转成https
|
||||
#return 301 https://$host$request_uri;
|
||||
|
||||
#(第二种)强制将http的URL重写成https
|
||||
rewrite ^(.*) https://$server_name$1 permanent;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
|
||||
ssl_certificate /etc/nginx/conf.d/cert/nginx.pem;
|
||||
ssl_certificate_key /etc/nginx/conf.d/cert/nginx.key;
|
||||
|
||||
location / {
|
||||
proxy_pass http://blog:4000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
location /twikoo {
|
||||
proxy_pass http://blog-twikoo:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user