diff --git a/.env.example b/.env.example index 763d84b..083b3de 100644 --- a/.env.example +++ b/.env.example @@ -7,6 +7,7 @@ POSTGRES_DB="" POSTGRES_PASSWORD="" NOTIFICATION_SERVER_PATH="" +NOTIFICATION_SERVICE_URL="" NOTIFICATION_SERVER_DB="" NOTIFICATION_SERVER_USER="" NOTIFICATION_SERVER_PASSWORD="" @@ -20,4 +21,6 @@ REDIS_PORT="" NEXT_JS_PATH="" NEXT_PUBLIC_VERSION="" NEXT_PUBLIC_API_URL="" -NEXT_PUBLIC_SERVER_SOCKET_URL="" \ No newline at end of file +NEXT_PUBLIC_SERVER_SOCKET_URL="" + +NGINX_CONFIG_PATH="" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 8d6094d..72a7ced 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,16 @@ services: + nginx: + image: nginx:1.27.5-alpine3.21 + container_name: nginx + restart: always + tty: true + ports: + - "8888:80" + volumes: + - ${NGINX_CONFIG_PATH}:/etc/nginx/conf.d + - ${NGINX_CONFIG_PATH}/logs:/var/log/nginx/ + + backend_db: image: postgres:17-alpine3.21 container_name: backend_db @@ -71,6 +83,7 @@ services: - NODE_ENV=production - DB_HOST=notification_db - DB_PORT=5432 + - SERVICE_URL=${NOTIFICATION_SERVICE_URL} - DB_USERNAME=${NOTIFICATION_SERVER_USER} - DB_PASSWORD=${NOTIFICATION_SERVER_PASSWORD} - DB_DATABASE=${NOTIFICATION_SERVER_DB} diff --git a/nginx/crm.conf b/nginx/crm.conf new file mode 100644 index 0000000..2c9d405 --- /dev/null +++ b/nginx/crm.conf @@ -0,0 +1,34 @@ +server { + listen 80; + charset utf-8; + + location ^~ /server { + rewrite ^/server(/.*)$ $1 break; + include fastcgi_params; + fastcgi_pass laravel:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME /var/www/laravel/public/index.php; + } + + location / { + proxy_pass http://nextjs:3106; + } + + location /notification { + proxy_pass http://notification_server:3023; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + 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_read_timeout 86400; + } + +# listen 443 ssl; # managed by Certbot +# ssl_certificate /etc/letsencrypt/live/crm.witel.ir/fullchain.pem; # managed by Certbot +# ssl_certificate_key /etc/letsencrypt/live/crm.witel.ir/privkey.pem; # managed by Certbot +# include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot +# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot +}