iam_production_deployment_guide
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| iam_production_deployment_guide [2026/02/18 08:32] – [4. Create & Encrypt Secrets] pradnya | iam_production_deployment_guide [2026/02/26 12:47] (current) – [cPanel's userdata include] pradnya | ||
|---|---|---|---|
| Line 163: | Line 163: | ||
| < | < | ||
| services: | services: | ||
| - | postgres: | + | |
| - | image: postgres: | + | image: postgres: |
| - | container_name: | + | container_name: |
| - | environment: | + | environment: |
| - | POSTGRES_DB: | + | POSTGRES_DB: |
| - | POSTGRES_USER: | + | POSTGRES_USER: |
| - | POSTGRES_PASSWORD_FILE: | + | POSTGRES_PASSWORD_FILE: |
| - | volumes: | + | volumes: |
| - | - / | + | - / |
| - | - / | + | - / |
| - | healthcheck: | + | healthcheck: |
| - | test: [" | + | test: [" |
| - | interval: 5s | + | interval: 5s |
| - | networks: | + | networks: |
| - | - iam_network | + | - iam_network |
| - | keycloak: | + | |
| - | image: quay.io/ | + | image: quay.io/ |
| - | container_name: | + | container_name: |
| - | command: start | + | command: start |
| - | ports: | + | ports: |
| - | - " | + | - " |
| - | environment: | + | environment: |
| - | KC_DB: postgres | + | KC_DB: postgres |
| - | KC_DB_URL: jdbc: | + | KC_DB_URL: jdbc: |
| - | KC_DB_USERNAME: | + | KC_DB_USERNAME: |
| - | KC_DB_PASSWORD_FILE: | + | KC_DB_PASSWORD_FILE: |
| - | KC_BOOTSTRAP_ADMIN_USERNAME: | + | KC_BOOTSTRAP_ADMIN_USERNAME: |
| - | KC_BOOTSTRAP_ADMIN_PASSWORD_FILE: | + | KC_BOOTSTRAP_ADMIN_PASSWORD_FILE: |
| - | KC_HTTP_ENABLED: | + | KC_HTTP_ENABLED: |
| - | volumes: | + | volumes: |
| - | - / | + | - / |
| - | - / | + | - / |
| - | - / | + | - / |
| - | depends_on: | + | depends_on: |
| - | postgres: | + | postgres: |
| - | condition: service_healthy | + | condition: service_healthy |
| - | networks: | + | networks: |
| - | - iam_network | + | - iam_network |
| networks: | networks: | ||
| - | iam_network: | + | |
| - | driver: bridge | + | driver: bridge |
| </ | </ | ||
| + | |||
| ===== 6. Create Secure start-iam.sh ===== | ===== 6. Create Secure start-iam.sh ===== | ||
| Line 305: | Line 306: | ||
| docker exec keycloak_db \ | docker exec keycloak_db \ | ||
| pg_dump -U keycloak_user keycloak \ | pg_dump -U keycloak_user keycloak \ | ||
| - | > / | + | > / |
| </ | </ | ||
| Line 329: | Line 330: | ||
| </ | </ | ||
| + | |||
| + | ===== Proxy through NGINX - Droplet FIX ===== | ||
| + | |||
| + | To resolve on browser error "We are sorry… HTTPS required" | ||
| + | |||
| + | **Step 1: Install Nginx on Alma Linux** | ||
| + | |||
| + | bash | ||
| + | |||
| + | < | ||
| + | dnf install -y nginx | ||
| + | systemctl enable --now nginx | ||
| + | |||
| + | </ | ||
| + | |||
| + | **Step 2: Generate a self-signed certificate** | ||
| + | |||
| + | bash | ||
| + | |||
| + | < | ||
| + | mkdir -p / | ||
| + | openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ | ||
| + | -keyout / | ||
| + | -out / | ||
| + | -subj "/ | ||
| + | |||
| + | </ | ||
| + | |||
| + | **Step 3: Create Nginx config for Keycloak** | ||
| + | |||
| + | bash | ||
| + | |||
| + | < | ||
| + | nano / | ||
| + | |||
| + | </ | ||
| + | |||
| + | < | ||
| + | server { | ||
| + | listen 443 ssl; | ||
| + | server_name 64.227.190.56; | ||
| + | |||
| + | ssl_certificate | ||
| + | ssl_certificate_key / | ||
| + | |||
| + | # Security headers | ||
| + | add_header Strict-Transport-Security " | ||
| + | add_header X-Frame-Options SAMEORIGIN; | ||
| + | add_header X-Content-Type-Options nosniff; | ||
| + | |||
| + | location / { | ||
| + | proxy_pass http:// | ||
| + | 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; | ||
| + | proxy_buffer_size 128k; | ||
| + | proxy_buffers 4 256k; | ||
| + | proxy_busy_buffers_size 256k; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | server { | ||
| + | listen 80; | ||
| + | server_name 64.227.190.56; | ||
| + | return 301 https:// | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | Modified docker-compose.yml as follows | ||
| + | |||
| + | < | ||
| + | keycloak: | ||
| + | image: quay.io/ | ||
| + | container_name: | ||
| + | command: start | ||
| + | ports: | ||
| + | - " | ||
| + | environment: | ||
| + | KC_DB: postgres | ||
| + | KC_DB_URL: jdbc: | ||
| + | KC_DB_USERNAME: | ||
| + | KC_DB_PASSWORD: | ||
| + | KC_BOOTSTRAP_ADMIN_USERNAME: | ||
| + | KC_BOOTSTRAP_ADMIN_PASSWORD: | ||
| + | KC_HTTP_ENABLED: | ||
| + | KC_HTTP_PORT: | ||
| + | KC_PROXY_HEADERS: | ||
| + | KC_HOSTNAME: | ||
| + | KC_HOSTNAME_STRICT: | ||
| + | |||
| + | </ | ||
| + | |||
| + | Start NginX | ||
| + | |||
| + | < | ||
| + | systemctl restart nginx | ||
| + | |||
| + | </ | ||
| + | |||
| + | Check/ | ||
| + | |||
| + | **Configure Inbound Rules** | ||
| + | |||
| + | Add these inbound rules: | ||
| + | |||
| + | ^Type^Protocol^Port^Sources| | ||
| + | |HTTP|TCP|80|All IPv4, All IPv6| | ||
| + | |HTTPS|TCP|443|All IPv4, All IPv6| | ||
| + | |SSH|TCP|22| \\ All IPv4, All IPv6| | ||
| + | |||
| + | Allow Nginx to connect to local ports | ||
| + | < | ||
| + | |||
| + | | ||
| + | |||
| + | #or | ||
| + | |||
| + | setenforce 1 | ||
| + | |||
| + | </ | ||
| + | |||
| + | Stop docker and NginX and start again. | ||
| + | |||
| + | ===== cPanel' | ||
| + | |||
| + | **Step 1: Create the userdata directories** | ||
| + | |||
| + | bash | ||
| + | |||
| + | < | ||
| + | mkdir -p / | ||
| + | mkdir -p / | ||
| + | |||
| + | </ | ||
| + | |||
| + | **Step 2: Create HTTP proxy config** | ||
| + | |||
| + | bash | ||
| + | |||
| + | < | ||
| + | nano / | ||
| + | |||
| + | </ | ||
| + | |||
| + | Add: | ||
| + | |||
| + | < | ||
| + | RewriteEngine On RewriteRule ^(.*)$ https:// | ||
| + | |||
| + | **Step 3: Create HTTPS proxy config** | ||
| + | |||
| + | bash | ||
| + | |||
| + | < | ||
| + | |||
| + | </ | ||
| + | |||
| + | Add: | ||
| + | |||
| + | < | ||
| + | ProxyPreserveHost On\ | ||
| + | ProxyPass / http:// | ||
| + | ProxyPassReverse / http:// | ||
| + | RequestHeader set X-Forwarded-Proto " | ||
| + | RequestHeader set X-Forwarded-Port " | ||
| + | |||
| + | </ | ||
| + | |||
| + | **Step 4: Rebuild Apache config and restart** | ||
| + | |||
| + | bash | ||
| + | |||
| + | < | ||
| + | / | ||
| + | httpd -t | ||
| + | systemctl restart httpd | ||
| + | |||
| + | </ | ||
| + | |||
| + | Then test: | ||
| + | |||
| + | bash | ||
| + | |||
| + | < | ||
| + | curl -I https:// | ||
| + | |||
| + | </ | ||
| + | |||
| + | Expected result: | ||
| + | |||
| + | < | ||
| + | curl -I [[https:// | ||
| + | |||
| + | HTTP/1.1 302 Found Date: Thu, 26 Feb 2026 11:22:25 GMT | ||
| + | |||
| + | Server: Apache | ||
| + | |||
| + | Location: [[https:// | ||
| + | |||
| + | Referrer-Policy: | ||
| + | |||
| + | Strict-Transport-Security: | ||
| + | |||
| + | X-Content-Type-Options: | ||
| + | |||
| + | X-XSS-Protection: | ||
| + | |||
| + | mode=block | ||
| + | |||
| + | </ | ||
| + | |||
| + | Check for **Location: https:// | ||
| + | |||
| + | This is poining to correct directory and not apache direcoty with cgi folder. | ||
iam_production_deployment_guide.1771403532.txt.gz · Last modified: by pradnya
