Nginx配置示例文件
Nginx配置示例文件
nginx.conf
worker_processes 8;events {worker_connections 1024;
}http {include mime.types;default_type application/octet-stream;#access_log logs/access.log main;sendfile on;tcp_nopush on;keepalive_timeout 65;gzip on;# 设置缓存的路径和其他参数# proxy_cache_path path [levels=levels] keys_zone=name:size [inactive=time] [max_size=size] [loader_files=number] [loader_sleep=time] [loader_threshold=time];# 缓存路径 /data/nginx/cache 缓存结构为 2 层,即该路径下会有 2 层子目录,缓存文件会保存在最下层子目录# 缓存的 key 会保存在名为 web_cache 的内存区域,该内存区域大小为 50 m# 10 分钟内缓存没有被访问就会过期# 缓存文件最多占用 1g 空间proxy_cache_path ./cache levels=1:2 keys_zone=web_cache:1024m inactive=1000m max_size=10g;upstream cwbase {server 172.18.140.235:8082 weight=10 max_fails=3 fail_timeout=30s;}upstream fileview {server view.brc-beei.com:6869 weight=10 max_fails=3 fail_timeout=30s;}upstream thumbox {server 172.18.140.237:8080 weight=10 max_fails=3 fail_timeout=30s;}server {listen 443 ssl;server_name fileview.brc-ulife.com;#access_log logs/host.access.log main;#ssl on;ssl_certificate ../cert/fileview.brc-ulife.com.crt;ssl_certificate_key ../cert/fileview.brc-ulife.com.key;ssl_session_timeout 5m;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers on;#开启缓冲#proxy_buffering on;#proxy_buffer_size 1k;#proxy_buffers 24 4k;#proxy_busy_buffers_size 8k;#proxy_max_temp_file_size 1024m;#proxy_temp_file_write_size 32k;index index.html index.htm;# 开启gzipgzip on;# 启用gzip压缩的最小文件,小于设置值的文件将不会压缩gzip_min_length 1k;# gzip 压缩级别,1-9,数字越大压缩的越好,也越占用CPU时间,后面会有详细说明gzip_comp_level 9;# 进行压缩的文件类型。javascript有多种形式。其中的值可以在 mime.types 文件中找到。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 application/vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml;# 是否在http header中添加Vary: Accept-Encoding,建议开启gzip_vary on;# 禁用IE 6 gzipgzip_disable "MSIE [1-6]\.";# 设置压缩所需要的缓冲区大小 gzip_buffers 32 4k;# 设置gzip压缩针对的HTTP协议版本gzip_http_version 1.0;location / {#image on;#image_output on;root D:\DEFPATH;try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404index index.html index.htm;# 缓存使用前面定义的内存区域#proxy_cache web_cache;# 对于 200 和 304 的响应码进行缓存,过期时间为 1 分钟,这会覆盖前面定义的 10 分钟过期时间#proxy_cache_valid 200 304 100m;# 设置缓存的 key#proxy_cache_key $scheme$host$request_uri;} #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件#因此需要rewrite到index.html中,然后交给路由在处理请求资源location @router {rewrite ^.*$ /index.html last;}}server {listen 8000;server_name 172.18.140.235;location / {root D:\DEFPATH;index index.html index.htm;} }server {listen 443 ssl;server_name gsp.brc-ulife.com;#access_log logs/host.access.log main;#ssl on;ssl_certificate ../cert/gsp.brc-ulife.com.crt;ssl_certificate_key ../cert/gsp.brc-ulife.com.key;ssl_session_timeout 5m;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers on;#开启缓冲#proxy_buffering on;#proxy_buffer_size 1k;#proxy_buffers 24 4k;#proxy_busy_buffers_size 8k;#proxy_max_temp_file_size 1024m;#proxy_temp_file_write_size 32k;location / {#image on;#image_output on;add_header Cache-Control no-cache;proxy_set_header Host gsp.brc-ulife.com;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Real-IP $remote_addr;proxy_pass http://cwbase/;proxy_connect_timeout 30s;index login.aspx;# 缓存使用前面定义的内存区域proxy_cache web_cache;# 对于 200 和 304 的响应码进行缓存,过期时间为 1 分钟,这会覆盖前面定义的 10 分钟过期时间proxy_cache_valid 200 304 1m;# 设置缓存的 keyproxy_cache_key $scheme$host$request_uri;} }server {listen 8080;server_name 172.18.140.235;location / {add_header Cache-Control no-cache;proxy_set_header Host 172.18.140.235;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Real-IP $remote_addr;proxy_pass http://172.18.140.237:8080/;proxy_connect_timeout 30s;index index.html;} }server {listen 8443 ssl; server_name fileview.brc-ulife.com;ssl_certificate ../cert/fileview.brc-ulife.com.crt;ssl_certificate_key ../cert/fileview.brc-ulife.com.key;ssl_session_timeout 5m;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers on;root D:\Workspace\Jeecg\vue;index index.html index.htm;# 开启gzipgzip on;# 启用gzip压缩的最小文件,小于设置值的文件将不会压缩gzip_min_length 1k;# gzip 压缩级别,1-9,数字越大压缩的越好,也越占用CPU时间,后面会有详细说明gzip_comp_level 9;# 进行压缩的文件类型。javascript有多种形式。其中的值可以在 mime.types 文件中找到。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 application/vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml;# 是否在http header中添加Vary: Accept-Encoding,建议开启gzip_vary on;# 禁用IE 6 gzipgzip_disable "MSIE [1-6]\.";# 设置压缩所需要的缓冲区大小 gzip_buffers 32 4k;# 设置gzip压缩针对的HTTP协议版本gzip_http_version 1.0;location / {try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404index index.html index.htm;# 缓存使用前面定义的内存区域proxy_cache web_cache;# 对于 200 和 304 的响应码进行缓存,过期时间为 1 分钟,这会覆盖前面定义的 10 分钟过期时间proxy_cache_valid 200 304 100m;# 设置缓存的 keyproxy_cache_key $scheme$host$request_uri;}#对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件#因此需要rewrite到index.html中,然后交给路由在处理请求资源location @router {rewrite ^.*$ /index.html last;}#.......其他部分省略}}
Nginx配置示例文件相关推荐
- nginx 配置示例_Nginx位置指令示例
nginx 配置示例 The location directive within NGINX server block allows to route request to correct locat ...
- Nginx 配置示例
文章目录 Nginx主配置文件调优 Nginx HTTP跳转HTTPS Nginx代理PHP服务 Nginx作为代理服务器 Nginx作为负载均衡服务器 Nginx作为静态文件服务器 Nginx反向代 ...
- 解决因nginx配置导致文件上传失败的问题 The filed file exceeds its maximum permitted size of 1048576 bytes
解决因nginx配置问题导致文件上传失败的问题 1.问题背景 2.问题截图 3.问题分析 4.问题解决(修改nginx的配置) 5.解决之后的"后遗症"(截图) 6.分析并解决&q ...
- GitHub集成Circle CI(附 Circle CI 配置示例文件)
文章目录 GitHub 集成Circle CI CI(持续集成) 简单解释 CI 工具 Circle的使用 将GitHub项目授权给 Circle CI 书写 config.yml文件 测试 Circ ...
- nginx配置简单文件预览
1.目的 预览图片.pdf.txt 2.配置 #搭建文件预览 server { listen 8888; server_name preview.xxx.c ...
- nginx配置下载文件
nginx安装及下载文件 一.安装nginx 安装依赖包 //一键安装上面四个依赖 yum -y install gcc zlib zlib-devel pcre-devel openssl open ...
- Windows使用Nginx配置本地文件代理(查看本地资源或图片)
一.前言 我们在实际开发中会经常遇到把图片上传到服务器上,比如七牛云.阿里云.腾讯云一些提供服务的商家.但是我们的图片隐私也会泄露,所以我们还是上传到本地,使用Nginx来代理到我们本地图片.这样就可 ...
- nginx配置静态文件过期时间
1. 编辑虚拟主机配置文件/usr/local/nginx/conf/vhosts/huangzhenping.conf 说明:采用location方式 1 2 3 4 5 6 7 8 9 10 l ...
- Nginx配置单项SSL以及双向SSL
Https安全协议的由来? 在实现 HTTPS协议前,我们需要了解 SSL 协议,但其实我们现在使用的更多的是 TLS 加密通讯协议. 那么TLS是怎么保证明文消息被加密的呢?在OSI七层模型中,应用 ...
最新文章
- logisitic和softmax函数
- 一些查阅个人隐私信息的网站——国内的基本上都查不到
- CDH- 集群时间同步ntp问题解决
- python输入名字、输出欢迎你_python笔记3-输出输入、字符串格式化
- get all table's information concerned
- 人脸识别python face_recognize_【python+face_recognition】人脸识别初始
- python骨灰技巧_Pandas技巧,某骨灰级Pythoner经验总结,呕心沥血!
- win7一直显示正在启动_win7系统中提高启动速度并且禁用某些软件启动的操作小技巧...
- mysql报错Attempted to open a previously opened tablespace的解决办法
- oracle11g 查看表,oracle11g查看,添加表空间
- 如何理解5G空口(NR)?
- 请问这样写法,第二个container的内容怎么没有显示的呢?但是加上jumbotron就可以显示了,不明白。...
- 简书客户端的计数器功能扩展
- 我晕,原来是这个问题!
- 用Open Images Dataset V6制作yolo训练数据集(darknet版本)
- 2022-2028年中国半导体照明(LED)产业投资分析及前景预测报告(全卷)
- 2022年全球程序员平均薪资发布,中国排名很意外
- 计算机输入网站打不开,电脑打不开网页怎么办
- Caused by: redis.clients.jedis.exceptions.JedisConnectionException: JedisPubSub was not subscribed t
- 正态分布(用python画出相应的图)