Commit ca81a4f3 authored by Markus Mößler's avatar Markus Mößler
Browse files

added configuration for serving of static pages via nginx

parent 6e677a72
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
# .

services:

  nginx:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ../nginx/nginx_static.conf:/etc/nginx/nginx.conf:ro
      - ../react-frontend/my-react-app/build:/usr/share/nginx/html:ro
+10 −22
Original line number Diff line number Diff line
@@ -5,37 +5,25 @@ events { }

http {
    
    # upstream react {
    #     server react-frontend:3000;
    # }
    upstream react {
        server react-frontend:3000;
    }

    upstream tornado {
        server tornado-backend:8888;
    }

    server {
        listen 80;

        include /etc/nginx/mime.types; # after this serving of static .css works! (are included by default in nginx container)

        # Serve static frontend files
        root /usr/share/nginx/html;
        index index.html;

        # Proxy frontend
        location / {
            try_files $uri /index.html;
            proxy_pass http://react;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }

        # # Proxy frontend
        # location / {
        #     proxy_pass http://react;
        #     proxy_http_version 1.1;
        #     proxy_set_header Upgrade $http_upgrade;
        #     proxy_set_header Connection 'upgrade';
        #     proxy_set_header Host $host;
        #     proxy_cache_bypass $http_upgrade;
        # }

        # Proxy API calls to backend
        location /tornado-backend/ {
            proxy_pass http://tornado;
+21 −0
Original line number Diff line number Diff line
 
# nginx/nginx_static.conf

events { }

http {
    
    server {
        listen 80;

        include /etc/nginx/mime.types; # after this serving of static .css works! (are included by default in nginx container)

        # Serve static frontend files
        root /usr/share/nginx/html;
        index index.html;

        location / {
            try_files $uri /index.html;
        }
    }
}