I'm running docker-compose with vaultwarden image on internal port 8732, Nginx works as a proxy server outside natively, which is listening to the requests from 80/443 and forwarding them inside docker to 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;
}
CodePudding user response:
i have fixed this issue by commenting the line in nginx config:
#try_files $uri $uri/ =404;