Score:0

Nginx failed open /etc/nginx/html/sockjs-node - no such file or directory error

in flag

I am trying to dockerize three applications, two frontend applications using react and one nodejs backend application, the two frontend applications use the same backend with different ports.

The frontend (https://localhost/login) and backend (https://localhost:8443/api-portal and https://localhost:8443/api-adminportal) applications are working perfectly.

The problem is when i try acess the other front app (https://localhost:8443/adminportal/) I geting this error on nginx log:

172.19.0.1 - - [24/May/2022:13:25:42 +0000] "GET /sockjs-node HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36" "-"

2022/05/24 13:25:42 [error] 31#31: *15 open() "/etc/nginx/html/sockjs-node" failed (2: No such file or directory), client: 172.19.0.1, server: localhost, request: "GET /sockjs-node HTTP/1.1", host: "localhost:8443"

And in the browser firefox i getting this error:

Firefox can’t establish a connection to the server at wss://localhost:8443/sockjs-node.

Nginx conf.d file:

server {
    listen 80;
    server_name localhost 127.0.0.1 0.0.0.0;
    return 301 https://$server_name$request_uri;
}
    
server {
    listen 443 ssl;
    server_name localhost 127.0.0.1 0.0.0.0;

    ssl_certificate /etc/nginx/cert/cert.pem;
    ssl_certificate_key /etc/nginx/cert/key.pem;

    location / {
        proxy_pass http://fpr-frontend:3000/;
    }


    # include /etc/nginx/conf.d/koma/*.conf;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

server {
    listen 8443 ssl;
    server_name localhost 127.0.0.1 0.0.0.0;

    ssl_certificate /etc/nginx/cert/cert.pem;
    ssl_certificate_key /etc/nginx/cert/key.pem;

     location /adminportal/ {
        proxy_pass http://fpr-adminportal:3001/adminportal/;
    }

    location /api-adminportal/ {
        proxy_pass https://fpr-backend:3335/;
    }

    location /api-portal/ {
        proxy_pass https://fpr-backend:3333/;
    }

    # include /etc/nginx/conf.d/koma/*.conf;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;   
    }

}



docker-compose.yml file:

version: "3.2"

volumes:
  mongodata:

services:
  fpr-backend:
    build:
      context: .
      dockerfile: Dockerfile.backend
    image: fpr-backend
    env_file: ./config/fpr-backend.env
    environment:
      FRONTEND_URL: https://localhost
      FRONTEND_ADMIN_PORTAL_URL: https://localhost:8443/adminportal/
    
    depends_on:
      - mongo
    expose:
      - "3333"
      - "3335"
    ports:
      - "3333:3333/tcp"
      - "3335:3335/tcp"
    command: ["yarn", "start"]

  fpr-frontend:
    build:
      context: .
      dockerfile: Dockerfile.frontend
      args:
       VITE_BACKEND_URL: https://localhost:8443/api-portal/
    image: fpr-frontend
    env_file: ./config/fpr-frontend.env
    depends_on:
      - fpr-backend
    expose:
      - "3000"
    command: ["yarn", "serve", "--host=fpr-frontend", "--port=3000"]

  fpr-adminportal:

    stdin_open: true # docker run -i
    tty: true        # docker run -t
    build:
      context: .
      dockerfile: Dockerfile.adminportal
      args:
        PORT: 3001
        REACT_APP_API_URL: https://localhost:8443/api-adminportal/
  
    image: fpr-adminportal
    env_file: ./config/fpr-adminportal.env
    environment: 
      - PUBLIC_URL=https://localhost:8443/adminportal
    depends_on:
      - fpr-backend
    expose:
      - "3001"
    ports:
      - "3001:3001/tcp"
    command: ["yarn","dev"]  

  mongo:
    image: mongo
    env_file: ./config/mongo.env
    volumes:
      - mongodata:/etc/mongo


  nginx:
    image: nginx
    depends_on:
      - fpr-backend
      - fpr-frontend
      - fpr-adminportal
    volumes:
      - ./config/nginx/conf.d/:/etc/nginx/conf.d/
      - ./modules/fpr-backend/certificates/UserPortal:/etc/nginx/cert
    expose:
      - "443"
      - "8443"
    ports:
      - "8000:80/tcp"
      - "443:443/tcp"
      - "8443:8443/tcp"
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.