无法使用Nginx加载管理控制台Keycloack

eoxn13cs  于 2023-06-21  发布在  Nginx
关注(0)|答案(1)|浏览(151)

请帮我解决那个问题
使用docker compose在服务器上安装Keycloack,安装Nginx。配置nginx
服务器{

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;

server_name vm333333.52ssd.had.wf www.vm333333.52ssd.had.wf;

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

      location /keycloak/ {
        proxy_pass          http://localhost:8080/;
        proxy_set_header    Host               $host;
        proxy_set_header    X-Real-IP          $remote_addr;
        proxy_set_header    X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Host   $host;
        proxy_set_header    X-Forwarded-Server $host;
        proxy_set_header    X-Forwarded-Port   $server_port;
        proxy_set_header    X-Forwarded-Proto  $scheme;
    }
    
          location /admin/ {
        proxy_pass          http://localhost:8080/admin/;
        proxy_set_header    Host               $host;
        proxy_set_header    X-Real-IP          $remote_addr;
        proxy_set_header    X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Host   $host;
        proxy_set_header    X-Forwarded-Server $host;
        proxy_set_header    X-Forwarded-Port   $server_port;
        proxy_set_header    X-Forwarded-Proto  $scheme;

    }
version: '3'
services:
 keycloak:
  image: quay.io/keycloak/keycloak:latest
  container_name: keycloak
  restart: always
  ports:
    - 8080:8080

  volumes:
    - ./certs/fullchain.pem:/etc/x509/https/tls.crt
    - ./certs/privkey.pem:/etc/x509/https/tls.key

  environment:
    - KEYCLOAK_ADMIN=admin
    - KEYCLOAK_ADMIN_PASSWORD=password
    - KC_HOSTNAME=vm4422234.52ssd.had.wf
#    - KC_HOSTNAME_ADMIN=vm4422234.52ssd.had.wf
    - KEYCLOAK_FRONTEND_URL = vm4422234.52ssd.had.wf/admin
    - KC_HTTPS_CERTIFICATE_FILE=/etc/x509/https/tls.crt
    - KC_HTTPS_CERTIFICATE_KEY_FILE=/etc/x509/https/tls.key
#    - PROXY_ADDRESS_FORWARDING=true
  command:
    - start-dev

当我试图在keycloack管理控制台我得到标签加载管理用户界面,但什么也没有发生。问题是什么?enter image description here
当我试图在keycloack管理控制台我得到标签加载管理用户界面,但什么也没有发生。问题是什么?enter image description here

iyfjxgzm

iyfjxgzm1#

您在Nginx配置Using a reverse proxy guide中缺少要Map的资源路径。用于例如

location /resources/ {
        proxy_pass          http://localhost:8080/resources/;
        proxy_set_header    Host               $host;
        proxy_set_header    X-Real-IP          $remote_addr;
        proxy_set_header    X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Host   $host;
        proxy_set_header    X-Forwarded-Server $host;
        proxy_set_header    X-Forwarded-Port   $server_port;
        proxy_set_header    X-Forwarded-Proto  $scheme;

}

相关问题