0

I'm running docker-compose on internal port 8732, Nginx works as a proxy server, which is listening to the request from 80/443 and forwarding them to internal 8732. The problem is the static files (.css, .js, .png) not serving and getting error 404, while the main file successfully gets status 200. Here's my docker-compose file:

version: '3'

services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: always
    volumes:
      - ./vw-data:/data
    ports:
      - 8732:80
    environment:
      WEBSOCKET_ENABLED: "true"  # Enable WebSocket notifications.

Here's the Nginx config file:

# HTTPS configuration
server {

        # SSL configuration
        listen [::]:443 ssl default_server ipv6only=on;
        listen 443 ssl default_server;

        ssl_certificate /etc/letsencrypt/live/bw.example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/bw.example.com/privkey.pem;
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

        include /etc/letsencrypt/options-ssl-nginx.conf;
        # include snippets/snakeoil.conf;

        server_name bw.example.com;
        root /opt/vault;

        # index index.html index.htm index.nginx-debian.html;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                proxy_pass http://localhost:8732;
                try_files $uri $uri/ =404;      
        }

        #location ~ /\.ht {
        #       deny all;
        #}

}

#HTTP config
server {
    if ($host = bw.example.com) {
        return 301 https://$host$request_uri;
    }

        listen 80 default_server;
        listen [::]:80 default_server;

        server_name bw.example.com;
    return 404;

}

1 Answers1

0

i've fixed this by commenting/deleting line in nginx configuration file try_files

#try_files $uri $uri/ =404;      

try_files Checks the existence of files in the specified order and uses the first found file for request processing; the processing is performed in the current context.