Skip to content

Commit

Permalink
refactor: nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
marrouchi committed Sep 13, 2024
1 parent 3acc795 commit 85d42f3
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 422 deletions.
2 changes: 1 addition & 1 deletion api/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const config: Config = {
email: {
main: '[email protected]',
},
appName: 'Hexabot.io',
appName: 'Hexabot.ai',
apiUrl: 'http://localhost:4000',
appUrl: 'http://localhost:8081',
geocoder: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { Offline } from '../types';

const img_url =
'http://demo.hexabot.io/attachment/download/5c334078e2c41d11206bd152/myimage.png';
'http://demo.hexabot.ai/attachment/download/5c334078e2c41d11206bd152/myimage.png';

// Offline events
const offlineEventPayload: Offline.Event = {
Expand Down
29 changes: 18 additions & 11 deletions docker/.env.example
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# API & Common
NODE_ENV=dev
APP_DOMAIN=localhost
SSL_EMAIL=[email protected]
API_PORT=4000
APP_MONGO_EXPRESS_PORT=9000
APP_SMTP_4_DEV_PORT=9002
APP_SCRIPT_COMPODOC_PORT=9003
API_ORIGIN=http://localhost:4000
FRONTEND_ORIGIN=http://localhost:8080,http://localhost:8081,http://localhost:5173,http://localhost,http://localhost/*,*
MONGO_USER=dev_only
MONGO_PASSWORD=dev_only
MONGO_URI=mongodb://dev_only:dev_only@mongo:27017/
MONGO_DB=hexabot
NEXT_PUBLIC_API_ORIGIN=http://${APP_DOMAIN}:${API_PORT}
API_ORIGIN=http://${APP_DOMAIN}:${API_PORT}
FRONTEND_ORIGIN=http://${APP_DOMAIN}:8080,http://${APP_DOMAIN}:8081,http://${APP_DOMAIN}:5173,http://${APP_DOMAIN},http://${APP_DOMAIN}/*,*
JWT_SECRET=dev_only
JWT_EXPIRES_IN=60
SALT_LENGTH=12
Expand All @@ -25,12 +22,22 @@ PASSWORD_RESET_EXPIRES_IN=1h
CONFIRM_ACCOUNT_SECRET=dev_only
CONFIRM_ACCOUNT_EXPIRES_IN=1h
FRONTEND_DOCKER_IMAGE=linuxtry
I18N_TRANSLATION_FILENAME=messages

# Mongo configs
APP_MONGO_EXPRESS_PORT=9000
MONGO_USER=dev_only
MONGO_PASSWORD=dev_only
MONGO_URI=mongodb://dev_only:dev_only@mongo:27017/
MONGO_DB=hexabot

# SMTP Config for local dev env
APP_SMTP_4_DEV_PORT=9002
EMAIL_SMTP_HOST=smtp4dev
EMAIL_SMTP_PORT=25
EMAIL_SMTP_SECURE=false
EMAIL_SMTP_USER=dev_only
EMAIL_SMTP_PASS=dev_only
I18N_TRANSLATION_FILENAME=messages

# NLU Server
AUTH_TOKEN=token123
Expand All @@ -42,11 +49,11 @@ NLP_PORT=5000

# Frontend (Next.js)
APP_FRONTEND_PORT=8080
NEXT_PUBLIC_API_ORIGIN=http://localhost:4000/
NEXT_PUBLIC_API_ORIGIN=http://${APP_DOMAIN}:4000/
NEXT_PUBLIC_SSO_ENABLED=false

# Widget
APP_WIDGET_PORT=5173
REACT_APP_WIDGET_API_URL=http://localhost:4000
REACT_APP_WIDGET_API_URL=http://${APP_DOMAIN}:4000
REACT_APP_WIDGET_CHANNEL=offline
REACT_APP_WIDGET_TOKEN=token123
2 changes: 1 addition & 1 deletion docker/docker-compose.nginx.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ services:
nginx:
container_name: nginx
volumes:
- ./nginx/unsecure/:/etc/nginx:ro
- ./nginx/unsecure/:/etc/nginx/templates/
- /etc/localtime:/etc/localtime:ro
2 changes: 1 addition & 1 deletion docker/docker-compose.nginx.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
nginx:
container_name: nginx
volumes:
- ./nginx/secure/:/etc/nginx:ro
- ./nginx/secure/:/etc/nginx/templates/
- /etc/localtime:/etc/localtime:ro
- ./nginx/certbot/conf:/etc/letsencrypt
- ./nginx/certbot/www:/var/www/certbot
Expand Down
4 changes: 1 addition & 3 deletions docker/docker-compose.nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ services:
container_name: nginx
image: nginx:latest
restart: unless-stopped
env_file: .env
networks:
- app-network
ports:
- 80:80
- 443:443
volumes:
- ./nginx/unsecure/:/etc/nginx:ro
- /etc/localtime:/etc/localtime:ro
depends_on:
- api
- hexabot-frontend
Expand Down
6 changes: 3 additions & 3 deletions docker/init-letsencrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ if ! [ -x "$(command -v docker compose)" ]; then
exit 1
fi

domains=(demo.hexabot.io)
domains=(${APP_DOMAIN:-example.hexabot.ai})
rsa_key_size=4096
data_path="./nginx/certbot"
email="[email protected]" # Adding a valid address is strongly recommended
staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits
email="${SSL_EMAIL:-hello@hexabot.ai}" # Adding a valid address is strongly recommended
staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits

if [ -d "$data_path" ]; then
read -p "Existing data found for $domains. Continue and replace existing certificate? (y/N) " decision
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server {
listen 80;
server_name demo.hexabot.io;
server_name $APP_DOMAIN;

location / {
return 301 https://$host$request_uri;
Expand All @@ -13,12 +13,12 @@ server {

server {
listen 443 ssl;
server_name demo.hexabot.io;
server_name $APP_DOMAIN;
server_tokens off;
client_max_body_size 20M;

ssl_certificate /etc/letsencrypt/live/demo.hexabot.io/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/demo.hexabot.io/privkey.pem;
ssl_certificate /etc/letsencrypt/live/$APP_DOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/$APP_DOMAIN/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

Expand Down
20 changes: 0 additions & 20 deletions docker/nginx/secure/fastcgi.conf

This file was deleted.

139 changes: 0 additions & 139 deletions docker/nginx/secure/mime.types

This file was deleted.

39 changes: 0 additions & 39 deletions docker/nginx/secure/nginx.conf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server {
listen 80;
server_name localhost;
server_name $APP_DOMAIN;
server_tokens off;
client_max_body_size 20M;

Expand Down
20 changes: 0 additions & 20 deletions docker/nginx/unsecure/fastcgi.conf

This file was deleted.

Loading

0 comments on commit 85d42f3

Please sign in to comment.