user root;
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;
client_max_body_size 20m;
#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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#开启gzip压缩
gzip on;
#http的协议版本
gzip_http_version 1.0;
#IE版本1-6不支持gzip压缩,关闭
gzip_disable 'MSIE[1-6].';
#需要压缩的文件格式 text/html默认会压缩,不用添加
gzip_types text/css text/javascript application/javascript image/jpeg image/jpg image/png image/gif;
#设置压缩缓冲区大小,此处设置为4个8K内存作为压缩结果流缓存
gzip_buffers 4 8k;
#压缩文件最小大小
gzip_min_length 1k;
#压缩级别1-9
gzip_comp_level 9;
#给响应头加个vary,告知客户端能否缓存
gzip_vary on;
#反向代理时使用
gzip_proxied off;
#upstream myServer {
# server 154.8.232.150:8080; #设置tomcat端口
#}
#upstream myServer2 {
# server 154.8.232.150:7777; #设置corner server端口
#}
server {
listen 80;
server_name 154.8.232.150 binarydance.top corner.binarydance.top spacefly.cn;
charset utf-8;
#charset koi8-r;
#access_log logs/host.access.log main;
location /filestore {
alias /home/filestore/; #资源文件上传至此,预览直接nginx访问这里目录
}
location /corner/ {
proxy_pass http://154.8.232.150:7777; #服务地址和端口
}
location /nsfw/ {
proxy_pass http://154.8.232.150:5000; #python3的open-nsfw色情图片检测flask web服务地址和端口
}
location / {
#proxy_pass http://154.8.232.150:8080/home/;
root /root/binarydance/web/; #放弃tomcat作为web服务器,使用nginx作为web服务器,开启压缩处理和字符编码utf-8
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
server {
listen 80;
server_name wjff.binarydance.top;
charset utf-8;
location /filestore {
alias /home/filestore/; #资源文件上传至此,预览直接nginx访问这里目录
}
location / {
root /root/wj_ff/;
index index.html index.htm;
}
}
server {
listen 80;
server_name wjff.manage.binarydance.top;
charset utf-8;
location / {
proxy_pass http://jixujiaoyu-manage.xfxsoft.cn; #需要反代的域名
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# location /filestore {
# alias /home/filestore/; #资源文件上传至此,预览直接nginx访问这里目录
#}
#location / {
# root /root/wj_ff_manage/;
# index index.html index.htm;
# }
}
server {
listen 80;
server_name tgz.binarydance.top;
charset utf-8;
location / {
proxy_pass http://154.8.232.150:8888;
proxy_http_version 1.1;
proxy_read_timeout 3600s;
#启用支持websocket连接
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
nginx常用配置示例
于 2022-03-07 09:21:00 首次发布