Commit 950d170b authored by Mark Harding's avatar Mark Harding

(chore): allow for devs to use dev server vs ssr

parent fd2763ee
FROM nginx:1.13-alpine
WORKDIR /var/www/Minds
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/nginx.conf
COPY dev-ssr.conf /etc/nginx/conf.d/dev.conf
COPY nginx_entrypoint_dev.sh /nginx_entrypoint_dev.sh
ENTRYPOINT /nginx_entrypoint_dev.sh
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80 default ipv6only=on;
listen 8080;
root /var/www/Minds/front/dist;
index index.php index.html;
server_name _;
error_log /dev/stdout warn;
access_log off;
if ($host = 'minds.com' ) {
rewrite ^/(.*)$ https://www.minds.com/$1 permanent;
}
#if ($http_x_forwarded_proto != "https") {
# rewrite ^(.*)$ https://$host$REQUEST_URI permanent;
#}
sendfile off;
location / {
port_in_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://front:4200/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
}
location ~ ^(/api|/fs|/icon|/carousel) {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,X-No-Cache';
rewrite ^(.+)$ /index.php last;
}
location ~* \.(png|jpg|jpeg|gif|ico|js|css)$ {
expires 1y;
log_not_found off;
}
location ~ (.woff|.tff) {
add_header 'Access-Control-Allow-Origin' *;
}
location ~ (composer.json|composer.lock|.travis.yml){
deny all;
}
location @rewrite {
rewrite ^(.+)$ /index.php last;
}
# Do not cache by default
set $no_cache 1;
# Cache GET requests by default
if ($request_method = GET){
set $no_cache 0;
}
# Do not cache if we have a cookie set
if ($http_cookie ~ "(mindsperm)" ){
set $no_cache 1;
}
# Do not cache if we have a logged in cookie
if ($cookie_minds_sess) {
set $no_cache 1;
}
# pass the PHP scripts to FastCGI server listening on socket
location ~ \.php$ {
add_header X-Cache $upstream_cache_status;
add_header No-Cache $no_cache;
add_header X-No-Cache $no_cache;
fastcgi_cache fastcgicache;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_buffers 64 32k;
fastcgi_buffer_size 64k;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/Minds/engine/index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires 5d;
}
location ~ /\. {
log_not_found off;
deny all;
}
}
......@@ -31,7 +31,7 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://front:4200/;
proxy_pass http://host.docker.internal:4200;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
......@@ -49,11 +49,6 @@ server {
rewrite ^(.+)$ /index.php last;
}
location ~* \.(png|jpg|jpeg|gif|ico|js|css)$ {
expires 1y;
log_not_found off;
}
location ~ (.woff|.tff) {
add_header 'Access-Control-Allow-Origin' *;
}
......@@ -106,9 +101,9 @@ server {
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires 5d;
}
# location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
# expires 5d;
# }
location ~ /\. {
log_not_found off;
......@@ -125,11 +120,4 @@ server {
proxy_max_temp_file_size 0;
}
# Proxy to Angular dev server (assets)
location ^~ /en/ {
proxy_pass http://host.docker.internal:4200;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_max_temp_file_size 0;
}
}
server {
listen 80;
listen [::]:80 default ipv6only=on;
root /dist;
index index.php index.html;
index index.html;
server_name _;
error_log /dev/stdout warn;
access_log off;
......
......@@ -28,6 +28,21 @@ http {
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/json
application/xml
application/rss+xml
image/svg+xml;
fastcgi_cache_path /tmp/nginx_cache
levels=1:2
......
......@@ -122,21 +122,21 @@ services:
- ./engine:/var/www/Minds/engine:delegated
front:
image: node:13-alpine
working_dir: /var/www/Minds/front/
entrypoint: "node /var/www/Minds/front/dist/server"
build:
context: ./front/dist
dockerfile: ../containers/server/Dockerfile
networks:
- app
volumes:
- ./front/:/var/www/Minds/front:delegated
- ./front/dist:/dist:delegated
nginx:
build:
context: ./containers/nginx
dockerfile: ./Dockerfile.dev
dockerfile: ./Dockerfile.dev # Change to ./Dockerfile.dev-ssr to use SSR locally
mem_limit: 512MB
depends_on:
- front
# - front # Uncomment out this line if you want to use SSR locally
- php-fpm
ports:
- "8080:80"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment