Keycloak docker HTTPS-REQUIRED with nginx ssl

后端 未结 1 761
醉话见心
醉话见心 2021-02-10 09:19

I am using keycloak for production for the first time. I run keycloak on my local machine and never faced this issue. First I am using docker to run keycloak server

1条回答
  •  北荒
    北荒 (楼主)
    2021-02-10 10:22

    Correct structure

    server {
        listen 80 default_server;
        listen [::]:80 default_server;
    
    
        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 test.com www.test.com;
    
        location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
        }
    
    
    
    
    
            return 301 https://$server_name$request_uri;
    }
    
    
    server {
        # SSL configuration
        #
    
        #listen 443 ssl http2 default_server;
        listen 443 ssl default_server;
        #listen [::]:443 ssl http2 default_server; # does not work properly with Angular, TODO research about this
        listen [::]:443 ssl default_server;
    
        expires $expires;
        location /auth/ {
                proxy_pass http://x.x.x.x:9090/auth/;
    
              proxy_http_version 1.1;
    
              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-Proto  $scheme;
        }  
        include snippets/ssl-test.com.conf;
        include snippets/ssl-params.conf;
    
    }
    

    0 讨论(0)
提交回复
热议问题