#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#图片查看
server {
listen 8888;
server_name localhost; #你的IP;
location ~ .*\.(gif|jpg|jpeg|png)$ {
root D:/ruoyi/uploadPath/upload ; #你的图片资源路径
autoindex on; #自动开启目录访问权限
index index.html;
}
}
#连接后台访问
server {
listen 80; # 监听的端口
server_name localhost; #自己的服务器地址; # 域名或ip
client_max_body_size 50M;
location / { # 访问路径配置
root /usr/local/vue/dist/;# 根目录
try_files $uri $uri/ /index.html;
index index.html index.htm; # 默认首页
}
location /prod-api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://localhost:8080/;
}
}
#http转发
server {
listen 8085; # 监听的端口
server_name localhost; #自己的服务器地址; # 域名或ip
client_max_body_size 50M;
location /{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://172.19.1.2:8085/;#转发ip
}
}
map $http_upgrade $connection_upgrade{
default upgrade;
'' close;
}
#webSocket转发
server {
listen 8086; # 监听的端口
server_name localhost; #自己的服务器地址; # 域名或ip
client_max_body_size 50M;
location /{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://172.19.1.2:8086/;#转发ip
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
#文件下载
server {
listen 90;
server_name localhost;
charset utf-8;
location /download {
alias D:/ruoyi/htmlToPdf/;
if ($request_filename ~* ^.*?\.(html|doc|pdf|zip|docx|txt)$) {
add_header Content-Disposition attachment;
add_header Content-Type application/octet-stream;
}
sendfile on; # 开启高效文件传输模式
autoindex on; # 开启目录文件列表
autoindex_exact_size on; # 显示出文件的确切大小,单位是bytes
autoindex_localtime on; # 显示的文件时间为文件的服务器时间
}
}
server {
listen 443 ssl;
server_name www.yuming.cn;#域名
ssl_certificate C:/nginx_key/arcdata.cn.pem;#ssl文件绝对路径
ssl_certificate_key C:/nginx_key/arcdata.cn.key;#ssl文件绝对路径
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root C:/uploadPath/upload; #映射路径
index index.html index.htm;
}
}
}
nginx相关配置
于 2023-12-13 16:33:40 首次发布