Run Keycloak on Amazon Linux 2 without Docker

Introduction

I have summarized the fastest procedure for myself to tell customers "Keycloak is such a UI". If only you need to touch it, docker to your local machine

# docker run jboss/keycloak

This should be the fastest.

According to Keycloak documentation Server Installation and Configuration Guide https://keycloak-documentation.openstandia.jp/master/ja_JP/server_installation/index.html

The system requirements are as follows

So, I will build it with EC2 free frame t2.micro.

setup

Proceed almost by default and allow ssh and https for inbound security groups. After entering the server with ssh, execute the command as root below.

# amazon-linux-extras install -y java-openjdk11 nginx1

Once java and nginx are installed, install keycloak DL.

# cd /usr/local/src/
# wget https://github.com/keycloak/keycloak/releases/download/12.0.1/keycloak-12.0.1.tar.gz
# tar zxf keycloak-12.0.1.tar.gz
# mv keycloak-12.0.1 /opt/keycloak

Creating a root user

# cd /opt/keycloak/
# ./bin/add-user-keycloak.sh -r master -u user1 -p password1
Added 'user1' to '/opt/keycloak/standalone/configuration/keycloak-add-user.json', restart server to load user

Change standalone settings (otherwise you'll be addicted to nginx integration)

# cp ./standalone/configuration/standalone.xml ./standalone/configuration/standalone.xml.org
# vi ./standalone/configuration/standalone.xml
# diff ./standalone/configuration/standalone.xml.org ./standalone/configuration/standalone.xml
483c483
<                 <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
---
>                 <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true" proxy-address-forwarding="true"/>

Start keycloak

# ./bin/standalone.sh -b=0.0.0.0 &

nginx settings

# cp -p nginx.conf nginx.conf.org
# vi nginx.conf
# diff nginx.conf.org nginx.conf
58,67c58,67
< #    server {
< #        listen       443 ssl http2;
< #        listen       [::]:443 ssl http2;
< #        server_name  _;
< #        root         /usr/share/nginx/html;
< #
< #        ssl_certificate "/etc/pki/nginx/server.crt";
< #        ssl_certificate_key "/etc/pki/nginx/private/server.key";
< #        ssl_session_cache shared:SSL:1m;
< #        ssl_session_timeout  10m;
---
>     server {
>         listen       443 ssl http2;
>         listen       [::]:443 ssl http2;
>         server_name  _;
>         root         /usr/share/nginx/html;
>
>         ssl_certificate "/etc/nginx/crt.pem";
>         ssl_certificate_key "/etc/nginx/key.pem";
>         ssl_session_cache shared:SSL:1m;
>         ssl_session_timeout  10m;
69,81c69,92
< #        ssl_prefer_server_ciphers on;
< #
< #        # Load configuration files for the default server block.
< #        include /etc/nginx/default.d/*.conf;
< #
< #        error_page 404 /404.html;
< #            location = /40x.html {
< #        }
< #
< #        error_page 500 502 503 504 /50x.html;
< #            location = /50x.html {
< #        }
< #    }
---
>         ssl_prefer_server_ciphers on;
>
>         proxy_set_header Host $host;
>         proxy_set_header X-Real-IP $remote_addr;
>         proxy_set_header X-Forwarded-Host $host;
>         proxy_set_header X-Forwarded-Server $host;
>         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>         proxy_set_header X-Forwarded-Proto $scheme;
>
>         # Load configuration files for the default server block.
>         include /etc/nginx/default.d/*.conf;
>
>         error_page 404 /404.html;
>             location = /40x.html {
>         }
>
>         error_page 500 502 503 504 /50x.html;
>             location = /50x.html {
>         }
>
>         location / {
>             proxy_pass http://127.0.0.1:8080;
>         }
>    }
# vi /etc/nginx/crt.pem
# vi /etc/nginx/key.pem

Start nginx

# systemctl start nginx

the end. You should be able to open it by accessing the domain with this. img1.png

After transitioning to the Administration Console, log in as the created root user img2.png

img3.png I was able to log in, so it was a success.

The rest will be learned from now on. that's all~

Recommended Posts

Run Keycloak on Amazon Linux 2 without Docker
[Note] Run Django on Amazon Linux 2
Run docker-compose on Amazon Linux2 on ARM64
Run cron on Amazon Linux (set on Linux)
Run Kali Linux on Windows with GUI (without VirtualBox)
Install tomcat 5.5 on Amazon Linux.
Install Docker on Arch Linux and run it remotely
Use sshpass on Amazon linux2
Install Homebrew on Amazon Linux 2
Run IPython Notebook on Docker
Install strongSwan 5.9.1 on Amazon Linux 2
Run Amazon Linux 2 in VirtualBox
Run FreeBSD on Linux + qemu
Install oracle java8 on amazon linux2
Try installing OpenAM on Amazon Linux
Completion of docker command on Linux
Install pyenv on EC2 (Amazon Linux)
Run TensorFlow Docker Image on Python3
Run Matplotlib on a Docker container
[Linux] Docker environment construction on Redhat
[Note] Install Imagick on Amazon Linux2
Introduce Python 3.5.2 environment on Amazon Linux
Create a Docker container image with JRE8 / JDK8 on Amazon Linux
I'll install Ruby on EC2 (Amazon Linux2) 2020
Install scipy on Linux without internet connection
Use Numpy, Scipy, scikit-learn on Amazon Linux
How to update php on Amazon linux 2
Build an LNPP environment on Amazon Linux 2
Learn sshd_config and authorized_keys (on Amazon Linux 2)
Upgraded mysql on Cloud9 (Amazon Linux) (5.5 to 5,7)
How to install Anisble on Amazon Linux 2
Run bootgen on Debian GNU / Linux, Ubuntu
Dockerfile: Install Docker on your Linux server
Run matplotlib on a Windows Docker container
Install Python 3.8, Pip 3.8 on EC2 (Amazon Linux 2)
Run Linux on ARM architecture with QEMU
[Linux] Build a Docker environment with Amazon Linux 2
Run a batch of Python 2.7 with nohup on Amazon Linux AMI on EC2
Install Python3 and Django on Amazon Linux (EC2) and run your web server
Run Debian (Linux) & LXQt on Athlon 200GE (AMD)
Put Python3 in Docker container of Amazon Linux2
Install PHP 7 series on Amazon Linux 2 with Amazon Linux Extras
[Node] [npm] Install npm packeage on MacOS / Linux without sudo
Publish your Django app on Amazon Linux + Apache + mod_wsgi
Set up Docker on Oracle Linux (7.x) with Vagrant
Create an environment for MkDocs on Amazon Linux (attempted)
Compile and install MySQL-python for python2.7 on amazon linux
[AWS EC2] How to install Maven on Amazon Linux 2
How to build a Python environment on amazon linux 2
Announcing the availability of Java 11 LTS on Amazon Linux 2
[AWS] How to expand disk space on Amazon linux
Daemonizing processes on Linux
jblas on Arch Linux
Install docker on Fedora31
Linux (WSL) on Windows
NAT router on Linux
Run Django on PythonAnywhere
Run mysqlclient on Lambda
Develop .NET on Linux
Wake on lan on Linux
OpenVPN Summary + Amazon Linux2