PlayEdu/docker/nginx/conf/nginx.conf
2024-06-05 17:24:49 +08:00

131 lines
4.7 KiB
Nginx Configuration File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

client_max_body_size 50m;
server {
# 监听端口号9800
listen 9800;
# 禁用绝对重定向
# 如果没有设置该配置项当Nginx重定向时它将使用绝对路径这意味着当用户访问一个虚拟主机时
# Nginx可能会将他们重定向到另一个主机的URL这可能会导致安全问题和用户体验问题。因此通过
# 设置 absolute_redirect off Nginx将使用相对路径进行重定向以确保用户在同一主机上进
# 行重定向,而不会遇到上述问题。
absolute_redirect off;
# 匹配任何主机名
server_name _;
# 指定Web应用程序的根目录
root /app/pc;
# 指定默认的索引文件为index.html
index index.html;
# 启用gzip压缩
gzip on;
gzip_static on;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_types text/plain application/javascript text/css application/xml text/javascript;
gzip_vary on;
# 将所有以/api/开头的请求代理到本地地址为127.0.0.1:9898的Web应用程序后端服务器
location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9898/;
}
# 处理所有不以/api/开头的请求尝试查找匹配的文件如果没有找到则返回index.html
location ~* ^/(?![api].*) {
try_files $uri /index.html;
}
}
server {
# 监听端口号9801
listen 9801;
# 禁用绝对重定向
# 如果没有设置该配置项当Nginx重定向时它将使用绝对路径这意味着当用户访问一个虚拟主机时
# Nginx可能会将他们重定向到另一个主机的URL这可能会导致安全问题和用户体验问题。因此通过
# 设置 absolute_redirect off Nginx将使用相对路径进行重定向以确保用户在同一主机上进
# 行重定向,而不会遇到上述问题。
absolute_redirect off;
# 匹配任何主机名
server_name _;
# 指定Web应用程序的根目录
root /app/h5;
# 指定默认的索引文件为index.html
index index.html;
# 启用gzip压缩
gzip on;
gzip_static on;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_types text/plain application/javascript text/css application/xml text/javascript;
gzip_vary on;
# 将所有以/api/开头的请求代理到本地地址为127.0.0.1:9898的Web应用程序后端服务器
location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9898/;
}
# 处理所有不以/api/开头的请求尝试查找匹配的文件如果没有找到则返回index.html
location ~* ^/(?![api].*) {
try_files $uri /index.html;
}
}
server {
# 监听端口号9900
listen 9900;
# 禁用绝对重定向
# 如果没有设置该配置项当Nginx重定向时它将使用绝对路径这意味着当用户访问一个虚拟主机时
# Nginx可能会将他们重定向到另一个主机的URL这可能会导致安全问题和用户体验问题。因此通过
# 设置 absolute_redirect off Nginx将使用相对路径进行重定向以确保用户在同一主机上进
# 行重定向,而不会遇到上述问题。
absolute_redirect off;
# 匹配任何主机名
server_name _;
# 指定Web应用程序的根目录
root /app/admin;
# 指定默认的索引文件为index.html
index index.html;
# 启用gzip压缩
gzip on;
gzip_static on;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_types text/plain application/javascript text/css application/xml text/javascript;
gzip_vary on;
# 将所有以/api/开头的请求代理到本地地址为127.0.0.1:9898的Web应用程序后端服务器
location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9898/;
}
# 处理所有不以/api/开头的请求尝试查找匹配的文件如果没有找到则返回index.html
location ~* ^/(?![api].*) {
try_files $uri /index.html;
}
}
server {
# 监听端口号80
listen 9700;
# 匹配任何主机名
server_name _;
# 指定Web应用程序的根目录
root /app/pc;
# 指定默认的索引文件为index.html
index index.html;
# 将所有请求代理到本地地址为127.0.0.1:9898的Web应用程序后端服务器
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9898/;
}
}