博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx 配置文件
阅读量:6475 次
发布时间:2019-06-23

本文共 4767 字,大约阅读时间需要 15 分钟。

#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;
#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;
# 负载均衡
#upstream xtqg0304{
# ip_hash;
# hash $request_uri;
# server 127.0.0.1:8001 down;
# server 127.0.0.1:8002 backup;
# server 127.0.0.1:8003 max_fails=1 fail_timeout=10s;
#}
#proxy_cache_path /xtag0304/cache levels=1:2 keys_zone=xtqg0304_cache:10m max_size=10g inactive=60m use_temp_path=off;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#sendfile on; gzip 时开启
#access_log logs/host.access.log main;
#location /mystatus {
# stub_status;
#}
location / {
#expires 24h; 缓存设置相关
#add_header Access-Control-Allow-Origin *; 允许所有的跨域访问
#add_header Access-Control-Allow-Origin http://www.baidu.com; 允许跨域访问的地址
#add_header Access-Control-Allow-Method GET,POST,PUT,DELETE,OPTIONS; 允许跨域访问的方法
root html;
#random_index on; 随机主页面
#allow 10.18.72.34/70; 允许的ip访问
#deny all; 其他所有ip都不能访问
#deny 10.18.72.34; 不允许的ip访问
#allow all; 允许所有IP访问
#auth_basic "Auth access test! input your passward";
#auth_basic_user_file conf/htpasswd;
index index.html index.htm;
#sub_filter 'nginx' 'NGINX'; 过滤固定的字符串
#sub_filter_once off; 全部替换
}
#if($request_uri ~ ^/(login|register|password\/reset)){
# set $cookie_nocache 1;
#}
#location ~ ^/vehicel {
# rewrite ^/vehicel /test/ last; 实现url 重定向
# rewrite ^/vehicel /test/ break; 实现url 重定向
#}
#反向代理
#location ~ /test_proxy.html$ {
# proxy_cache xtqg0304_cache;
# proxy_pass http://127.0.0.1:8080;
# proxy_cache_valid 200 304 12h; 请求状态为200 304 缓存12小时
# proxy_cache_valid any 10m; 请求状态 存10分钟
# proxy_cache_key $host$uri$is_args$args; 缓存key 的重新定义
# proxy_no_cache $cookie_nocache $arg_nocache $arg_comments; 设置不缓存的url地址
# add_header Nginx-Cache "$upstream_cache_status"; 客户端头信息
# proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; 跳过本台负载的服务器
# proxy_redirect default;
# proxy_set_header Host $http_host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_connect_timeout 300;
# proxy_send_timeout 600;
# proxy_read_timeout 600;
# proxy_buffer_size 32k;
# proxy_buffering on;
# proxy_buffers 4 128k;
# proxy_busy_buffers_size 256k;
# proxy_max_temp_file_size 256k;
#}
#正向代理(需要将IP添加到浏览器的代理中HTTP中)
#resolver 8.8.8.8;
#location / {
# proxy_pass http://$http_host$request_uri;
#}
#压缩图片
#location ~ .*\.(jpg|gif|png)$ {
# gzip on;
# gzip_http_version 1.1;
# gzip_comp_level 2;
# 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;
# valid_referers none blocked 10.18.72.34 ~/google\./; 防盗链(防止盗用资源) 防止一些网站访问资源
# if($invalid_referer){
# return 403;
# }
# root html/images;
#}
#压缩txt和xml
#location ~ .*\.(txt|xml)$ {
# gzip on;
# gzip_http_version 1.1;
# gzip_comp_level 2;
# 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;
# root html/doc;
#}
#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 8080;
listen localhost:8080;
server_name localhost:8080;
location / {
root html/test8080;
index index.html index.htm;
}
}
# 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;
# }
#}
}

转载于:https://www.cnblogs.com/xtqg0304/p/9805630.html

你可能感兴趣的文章
利用 ACPI\\ACPI0003设备 判断笔记本还是台式机
查看>>
解决wampserver 服务无法启动
查看>>
ES6中Promise封装ajax的写法
查看>>
初次使用 VUX
查看>>
javascript 字符串转数字的简便写法
查看>>
html之div始终停留在屏幕中间部分
查看>>
Spring中jdbcTemplate的用户实例
查看>>
[模板] 快速傅里叶变换/FFT/NTT
查看>>
DecimalFormat 数据格式设置 SimpleDateFormat时间格式的用法介绍 --转载
查看>>
Android 的Margin和Padding属性以及支持的长度单位
查看>>
HDU ACM 1050 Moving Tables
查看>>
Django templates加载css/js/image等静态资源
查看>>
Eclipse C + GTK2.0环境构筑
查看>>
caffe solver
查看>>
Rhel6-heartbeat+lvs配置文档
查看>>
[CF340D]Bubble Sort Graph/[JZOJ3485]独立集
查看>>
ORACLE分科目统计每科前三名的学生的语句
查看>>
第一次冲刺--查看活动详情用户场景分析
查看>>
0317复利计算的回顾与总结
查看>>
函数对象
查看>>