Skip to content

DEV Auth Web

1. Overview

DEV Auth Web is the frontend application for the Surefy development authentication environment.

Setting Value
Application DEV Auth Web
Environment Development
Domain https://devapp.surefy.ai
EC2 Host ip-172-31-42-135
Docker Container authweb
Docker Host Port 3002
Container Port 3000
Docker Compose Directory /home/ubuntu/web/authweb
Docker Compose File authweb.yml
Environment File authweb.env
Systemd Service File authweb.service
Nginx Configuration /etc/nginx/sites-available/devapp.surefy.ai

2. Application Architecture

User Browser
     |
     | HTTPS (443)
     v
devapp.surefy.ai
     |
     v
Nginx Reverse Proxy
     |
     | HTTP (127.0.0.1:3002)
     v
Docker Container: authweb
     |
     | Container Port 3000
     v
Next.js DEV Auth Web

3. Docker Configuration

Application directory:

/home/ubuntu/web/authweb

Files:

File Purpose
authweb.yml Docker Compose configuration
authweb.env Application environment variables
authweb.service Systemd service configuration

Docker Image

139340340573.dkr.ecr.ap-south-1.amazonaws.com/surefy:dev-auth-web-dd291c5b91bde081d63d06b9198512d8fb5bfff9

Port Mapping

ports:
  - "3002:3000"
  • Host port: 3002
  • Container port: 3000

Docker Commands

Check container:

sudo docker ps --filter name=authweb

View logs:

sudo docker logs --tail 100 authweb

Follow logs:

sudo docker logs -f authweb

Restart container through Compose:

cd /home/ubuntu/web/authweb
sudo docker compose -f authweb.yml restart

4. Environment Configuration

Environment file:

/home/ubuntu/web/authweb/authweb.env

The application uses the following configuration keys:

Variable Purpose
NEXT_PUBLIC_AUTHX_URL Authentication API endpoint
NEXT_PUBLIC_REACHOUT_WEB_URL Reachout frontend URL
NEXT_PUBLIC_OUTREACH_WEB_URL Outreach frontend URL
NEXT_PUBLIC_ENGAGE_WEB_URL Engage frontend URL
NEXT_PUBLIC_SPRINT_WEB_URL Sprint frontend URL
REDIS_URL Redis connection configuration

Do not publish actual Redis credentials, passwords, tokens, or other secrets in documentation.

5. Systemd Service

Service file:

/home/ubuntu/web/authweb/authweb.service

The service manages the Docker Compose application and restarts it automatically when the service exits.

Check service status:

sudo systemctl status authweb

Restart service:

sudo systemctl restart authweb

Enable service at boot:

sudo systemctl enable authweb

View service logs:

sudo journalctl -u authweb -n 100 --no-pager

Follow service logs:

sudo journalctl -u authweb -f

6. Nginx Reverse Proxy

Nginx exposes the frontend using HTTPS and forwards requests to the Docker host port.

Configuration file:

/etc/nginx/sites-available/devapp.surefy.ai

Expected proxy target:

proxy_pass http://127.0.0.1:3002;

The Nginx configuration should include:

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;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

Nginx Operations

Test configuration:

sudo nginx -t

Reload Nginx:

sudo systemctl reload nginx

Check Nginx status:

sudo systemctl status nginx

Check configured domain and proxy:

sudo grep -nE 'server_name|proxy_pass' \
/etc/nginx/sites-enabled/devapp.surefy.ai

7. SSL Certificate

The domain uses HTTPS through Nginx and a Let's Encrypt certificate managed by Certbot.

Setting Value
Domain devapp.surefy.ai
HTTPS Port 443
Certificate Authority Let's Encrypt
Renewal Certbot automatic renewal, subject to successful renewal checks

Check certificate:

sudo certbot certificates

Verify SSL:

echo | openssl s_client \
  -connect devapp.surefy.ai:443 \
  -servername devapp.surefy.ai 2>/dev/null \
  | openssl x509 -noout -subject -dates -ext subjectAltName

8. Application Verification

Test the frontend locally:

curl -I http://127.0.0.1:3002

Test the public HTTPS endpoint:

curl -I https://devapp.surefy.ai

Check Docker port mapping:

sudo docker port authweb

9. Troubleshooting

Issue Action
Website unavailable Check DNS, Nginx and Docker status
502 Bad Gateway Verify the container and host port 3002
Frontend not loading Check authweb container logs
Authentication failure Verify NEXT_PUBLIC_AUTHX_URL
Incorrect redirects Verify frontend URL environment variables
Redis connection error Verify Redis availability and REDIS_URL
SSL error Check Certbot certificate and Nginx configuration
Container not starting Check Docker Compose and systemd logs

Useful Diagnostic Commands

sudo docker ps --filter name=authweb

sudo docker logs --tail 100 authweb

sudo systemctl status authweb

sudo nginx -t

sudo tail -100 /var/log/nginx/error.log

curl -I http://127.0.0.1:3002

curl -I https://devapp.surefy.ai

10. Security

  • Never commit passwords, tokens, API keys or Redis credentials.
  • Restrict SSH and infrastructure access to authorized users.
  • Use HTTPS for public application access.
  • Keep Docker images and application dependencies updated.
  • Avoid exposing internal application ports directly to the internet.
  • Review application and Nginx logs during incidents.

11. Environment Notes

This document describes the DEV Auth Web environment.

Update it whenever the frontend domain, Docker image, port mapping, environment variables, Nginx configuration or SSL settings change.