diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index aa3042a063..92cbbd50bc 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -105,7 +105,9 @@ services: volumes: - ./service_conf.yaml:/ragflow/conf/service_conf.yaml - ./ragflow-logs:/ragflow/logs - - ./nginx.conf:/etc/nginx/conf.d/ragflow.conf + - ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf + - ./nginx/proxy.conf:/etc/nginx/proxy.conf + - ./nginx/nginx.conf:/etc/nginx/nginx.conf networks: - ragflow restart: always diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index b75b578ca0..c8b39d1887 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -31,4 +31,6 @@ function task_bro(){ task_bro & task_exe & -$PY api/ragflow_server.py \ No newline at end of file +$PY api/ragflow_server.py + +wait; \ No newline at end of file diff --git a/docker/nginx.conf b/docker/nginx.conf deleted file mode 100644 index d81596017b..0000000000 --- a/docker/nginx.conf +++ /dev/null @@ -1,46 +0,0 @@ -upstream api_service { - server ragflow:9380; - keepalive 2000; -} - -server { - listen 80; - server_name ragflow.io; - - # gzip config - gzip on; - gzip_min_length 1k; - gzip_comp_level 9; - gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; - gzip_vary on; - gzip_disable "MSIE [1-6]\."; - - - # remove api server header - proxy_hide_header Access-Control-Allow-Origin; - proxy_hide_header Access-Control-Allow-Methods; - proxy_hide_header Access-Control-Allow-Headers; - - root /ragflow/web/dist; - - location / { - index index.html; - try_files $uri $uri/ /index.html; - } - - # Cache-Control: max-age态Expires - location ~ ^/static/(css|js|media)/ { - expires 10y; - access_log off; - } - - # api proxy - location ^~/v1 { - rewrite ^/v1/(.*)$ /$1 break; - proxy_pass http://api_service/; - proxy_set_header Host $http_host; - proxy_set_header Connection close; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Server $host; - } -} diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf new file mode 100644 index 0000000000..05c5029696 --- /dev/null +++ b/docker/nginx/nginx.conf @@ -0,0 +1,33 @@ +user root; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + client_max_body_size 82M; + + include /etc/nginx/conf.d/ragflow.conf; +} + diff --git a/docker/nginx/proxy.conf b/docker/nginx/proxy.conf new file mode 100644 index 0000000000..75f7087dc4 --- /dev/null +++ b/docker/nginx/proxy.conf @@ -0,0 +1,8 @@ +proxy_set_header Host $host; +proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +proxy_set_header X-Forwarded-Proto $scheme; +proxy_http_version 1.1; +proxy_set_header Connection ""; +proxy_buffering off; +proxy_read_timeout 3600s; +proxy_send_timeout 3600s; diff --git a/docker/nginx/ragflow.conf b/docker/nginx/ragflow.conf new file mode 100644 index 0000000000..453b724523 --- /dev/null +++ b/docker/nginx/ragflow.conf @@ -0,0 +1,28 @@ +server { + listen 80; + server_name _; + root /ragflow/web/dist; + + gzip on; + gzip_min_length 1k; + gzip_comp_level 9; + gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; + gzip_vary on; + gzip_disable "MSIE [1-6]\."; + + location /v1 { + proxy_pass http://ragflow:9380; + include proxy.conf; + } + + location / { + index index.html; + try_files $uri $uri/ /index.html; + } + + # Cache-Control: max-age~@~AExpires + location ~ ^/static/(css|js|media)/ { + expires 10y; + access_log off; + } +}