nginx.conf及server配置
#服务运行用户
user sysadmin www;
#工作进程数
worker_processes 4;
#错误日志位置
error_log /data/sysadmin/service_logs/nginx/error.log notice;
#PID位置
pid /var/run/nginx.pid;
#文件句柄打开
worker_rlimit_nofile 65535;
#
events {
use epoll;
worker_connections 20480;
}
#
http {
include mime.types;
default_type application/octet-stream;
log_format main '$time_local $status $request_time $upstream_response_time $remote_addr $upstream_addr $server_addr $host '
'"$bytes_sent" "$request_body" "$request" "$request_body" "$http_referer" "$http_user_agent" "$gzip_ratio" "$proxy_add_x_forwarded_for"';
access_log off;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
server_tokens off;
underscores_in_headers on;
more_set_headers "Server: name2.0";
more_clear_headers 'X-Powered-By';
#fastcgi全局配置参数
fastcgi_connect_timeout 15s;
fastcgi_send_timeout 15s;
fastcgi_read_timeout 15s;
#fastcgi buffer
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 128k;
#proxy全局配置参数
proxy_redirect off;
# proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#代理buffer
proxy_buffering on;
proxy_buffer_size 128k;
proxy_buffers 8 128k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 256k;
proxy_temp_path /dev/shm;
#客户端保持时长
keepalive_timeout 60;
#代理容借
#proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
#代理超时
proxy_connect_timeout 20s;
proxy_read_timeout 20s;
proxy_send_timeout 20s;
#压缩方式
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
##
##Nginx Status
##
server {
listen 0.0.0.0:80;
server_name _;
location /nginx_status {
stub_status on;
access_log off;
allow 192.168.39.42/32;
allow 10.0.0.0/8;
deny all;
}
}
resolver 192.168.2.180 192.168.2.182;
#limit_zone crawler $binary_remote_addr 10m;
include /data/sysadmin/service_deploy_data/collect/nginx_conf/vhosts/*.conf;
include vhosts/*.conf;
}
当web服务器收到静态的资源文件请求时,依据请求文件的后缀名在服务器的MIME配置文件中找到对应的MIME Type,再根据MIME Type设置HTTP Response的Content-Type,然后浏览器根据Content-Type的值处理文件。
对应项目名放置在conf下面,保存为conf文件
server {
listen 443;
server_name test.com;
default_type "text/html";
index index-dev.php index.html;
root /data/sysadmin/service_deploy_data/c2-hd-webplat/api.jpush.cn;
charset utf-8;
autoindex on;
client_max_body_size 10m;
ssl on;
ssl_certificate /usr/local/openresty/nginx/conf/server.crt;
ssl_certificate_key /usr/local/openresty/nginx/conf/server.key;
#安全限制
location ~* \.(sql|bak|inc|old)$ { return 403; }
#目录重定向
try_files $uri /index.php/$uri?$args;
#php处理
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_temp_path /dev/shm;
include fastcgi_params;
}
access_log /data/sysadmin/service_logs/nginx/api.jpush.cn_access.log main;
}
或者
server {
listen 80;
#server_name ~^(client\.)?(\w+\.)?(\w+)\.api\.domain\.com$;
server_name ~^(\w+\.)?(\w+)\.api\.domain\.com$;
index index.php;
charset utf-8;
autoindex off;
#
fastcgi_next_upstream error timeout invalid_header http_500 http_503;
#内部rewrite
rewrite ^/(.*)$ /index-test.php/$1 last;
#匹配PHP
location ~ .+\.php($|/) {
set $document_roots /data/sysadmin/service_deploy_data/c2-hd-webplat/$host;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass fastcgi_backend;
fastcgi_keep_conn on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_roots$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_temp_path /dev/shm;
include fastcgi_params;
}
#
access_log /data/sysadmin/service_logs/nginx/${host}_access.log main;
}
sql防注入:
local quoted_value = ndk.set_var.set_quote_sql_str(value) local quoted_value = ngx.quote_sql_str(value)404定向到一个指定的url:
server{
server_name b.com ;
listen xxxx;
error_page 404 /404_fallback;
......
location = /404_fallback{
rewrite ^(.*)$ http://a.com/;
}
}
- 区分不同协议:
location / {
content_by_lua_block {
if ngx.var.request_uri == '/fastcgi' then
ngx.exec('/@fastcgi')
else
ngx.exec('@http')
end
}
}
location @http {
proxy_pass http://backend/;
}
location @fastcgi {
fastcgi_pass fastcgi_backend;
}
laravel的nginx配置
server {
listen 80;
server_name base.api.axd.com;
root /data/php/gitlab.aixiangdao.com/base.api/public;
index index.html index.htm index.php;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
nginx.conf及server配置的更多相关文章
- Nginx入门讲解——初步认识了解nginx.conf配置文件以及配置多个虚拟主机
本文引自网络进攻学习之用https://blog.csdn.net/weixin_38111957/article/details/81080539 一. 引言上节文章讲述了如何用信号控制Nginx服 ...
- nginx详解(代理服务器的解释+nginx 在linux 下的安装+nginx.conf 中的配置解释)
一.概论 1.什么是代理服务器 代理服务器,客户机在发送请求时,不会直接发送给目的主机,而是先发送给代理服务器,代理服务接受客户机请求之后,再向主机发出,并接收目的主机返回的数据,存放在代理服务器的硬 ...
- Nginx.conf配置文件默认配置块略解
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #erro ...
- nginx.conf 中php-ftp配置
location ~ .php$ { root /home/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_par ...
- nginx配置tomcat负载均衡,nginx.conf配置文件的配置
- 虚拟主机ip配置,nginx.conf文件配置及日志文件切割
今天粗略整理了一下虚拟主机配置,nginx.conf文件的配置,及日志文件的切割,记录如下: nginx虚拟主机配置:1.IP地址配置,2.绑定ip地址和虚拟主机详情:1.ip地址的配置:ifconf ...
- VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三)
首先启动Nginx 1. 相关浏览 两个 Tomcat 配置: VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二) Nginx 安装配置启动: VMware Linu ...
- nginx 配置nginx.conf,负载均衡,逻辑分流
nginx 最重要的配置文件nginx.conf: 一般的配置我不做解释,网上到处都是,主要对主要的几点进行注释(如下) worker_processes ; error_log /data/logs ...
- nginx日志格式定义和nginx.conf配置模板说明
在http的功能里添加log_format模块,内容如下: log_format main escape=json '{ "@timestamp": "$time_iso ...
随机推荐
- Windows环境下,python webdriver环境搭建
最近刚开始学习selenium,这是我从虫师的<selenium2自动测试实战--基于Python语言>这本书上学到搭建环境的步骤,里面有加上我的一些总结,希望对大家有所帮助! 准备工 ...
- leetcode 174. 地下城游戏 解题报告
leetcode 174. 地下城游戏 一些恶魔抓住了公主(P)并将她关在了地下城的右下角.地下城是由 M x N 个房间组成的二维网格.我们英勇的骑士(K)最初被安置在左上角的房间里,他必须穿过地下 ...
- leetcode_day03
https://leetcode-cn.com/problems/container-with-most-water/ 题目:盛水最多的容器 给定 n 个非负整数 a1,a2,...,an,每个数代表 ...
- Java对字符串进行加密
package anli1; import java.util.Scanner; public class example { public static void main(String[]args ...
- 【转】Unity3D研究院之设置自动旋转屏幕默认旋转方向
http://www.xuanyusong.com/archives/2871 如下图所示,在处理屏幕默认旋转方向的时候可以在这里进行选择,上下左右一共是4个方向. 策划的需求是游戏采用横屏,但是要求 ...
- 【bzoj1511】[POI2006]OKR-Periods of Words KMP-next数组
原文地址:http://www.cnblogs.com/GXZlegend/p/6827027.html 题目描述 一个串是有限个小写字符的序列,特别的,一个空序列也可以是一个串. 一个串P是串A的前 ...
- 【Luogu】P3760异或和(权值树状数组)
题目链接 再次声明以后我见到位运算一定第一时间想把它拆成每一位算 本题就是有个前缀和sum[],然后让你求每一位有多少对i,j满足sum[i]-sum[j]在那一位上是1 考虑怎样才能减出1来 如果s ...
- 【BestCoder #45】
用家里的电脑来编程,各种不算 一开始15分钟刷掉T1和T2,然后就永远地卡在了T3... 后来看题解,傻了眼... 它强调的“只有一个答案”我还以为这是在提示我二分答案,于是我一直往权值线段树那个方向 ...
- 基站选址(base.c/cpp/pas)
基站选址(base.c/cpp/pas) 题目描述 有N个村庄坐落在一条直线上,第i(i>1)个村庄距离第1个村庄的距离为Di.需要在这些村庄中建立不超过K个通讯基站,在第i个村庄建立基站的费 ...
- 【ZBH选讲·模数和】
[问题描述]你是能看到第二题的friends呢.——laekovHja和Yjq在玩游戏,这个游戏中Hja给了Yjq两个数,希望Yjq找到一些非负整数使得这些数的和等于n,并且所有数模maaaaaaaa ...