Nginx配置记录
来源:互联网 发布:java web和前端开发 编辑:程序博客网 时间:2024/06/06 01:51
一、nginx默认配置
#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; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; 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; #} } # 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; # } #}}
二、配置
user root; #配置用户或者组
worker_processes 1; #允许生成的进程数
#error_log logs/error.log; #日志的路径,级别为:debug|info|notice|warn|error|crit|alert|emerg
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid; #指定nginx进程运行文件存放地址
events {
accept_mutex on; #设置网络连接序列化,默认为on.可以防止惊群现象发生。
#惊群现象:多线程下等待同一个socket事件,当这个事件发生时,这些线程被同时唤醒,就是惊群现象
multi_accept on; #设置一个进程是否同时接收多个网络链接,默认为off
worker_connections 1024;#最大连接数
}
worker_processes 1; #允许生成的进程数
#error_log logs/error.log; #日志的路径,级别为:debug|info|notice|warn|error|crit|alert|emerg
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid; #指定nginx进程运行文件存放地址
events {
accept_mutex on; #设置网络连接序列化,默认为on.可以防止惊群现象发生。
#惊群现象:多线程下等待同一个socket事件,当这个事件发生时,这些线程被同时唤醒,就是惊群现象
multi_accept on; #设置一个进程是否同时接收多个网络链接,默认为off
worker_connections 1024;#最大连接数
}
http {
include mime.types; #文件的扩展名与文件类型的映射表
default_type application/octet-stream;#默认文件类型,默认为text/plain
#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; #允许sendfile方式传输文件,默认为off
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65; #连接超时时间,默认为75s
#gzip on;
client_max_body_size 1000m; #设置文件最大上传数,默认为1M
server {
listen 80; #监听的端口
listen 81;
server_name www.pop.com pop.com; #监听的地址
include mime.types; #文件的扩展名与文件类型的映射表
default_type application/octet-stream;#默认文件类型,默认为text/plain
#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; #允许sendfile方式传输文件,默认为off
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65; #连接超时时间,默认为75s
#gzip on;
client_max_body_size 1000m; #设置文件最大上传数,默认为1M
server {
listen 80; #监听的端口
listen 81;
server_name www.pop.com pop.com; #监听的地址
access_log logs/access.log main;
deny 42.120.145.0/24; #拒绝的端口
deny 42.120.145.0/24; #拒绝的端口
location / {
#root /data1/webserver/upload/update/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://127.0.0.1:8080;
client_max_body_size 1000m;
}
location /qrcode {
autoindex on;
root html;
index index.html index.htm;
}
}
server {
listen 8088;
server_name 47.93.115.66;
deny 42.120.145.0/24;
location / {
#root /data1/webserver/upload/update/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://127.0.0.1:8080;
client_max_body_size 1000m;
}
location /qrcode {
autoindex on;
root html;
index index.html index.htm;
}
}
server {
listen 80;
server_name file.pop.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /data1/webserver/upload/;
}
}
server {
listen 8084;
server_name 47.93.115.66;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /data1/webserver/upload/;
}
}
server {
listen 80;
server_name app.pop.com;
#charset koi8-r;
#
#
#
# #access_log logs/host.access.log main;
#
location / {
root /data1/webserver/upload/;
}
}
三、Nginx常用命令
1、启动nginx
./nginx -c /usr/local/nginx/nginx.conf
2、关闭nginx
先查看nginx进程号:ps -ef |grep nginx
从容关闭nginx: kill -QUIT nginx主进程号
立刻关闭:kill -TERM nginx主进程号
强制关闭:kill -9 nginx主进程号
0 0
- nginx配置记录
- nginx安装配置记录
- nginx安装配置记录
- Nginx配置记录
- Nginx配置记录
- Nginx 配置项记录
- 记录服务端nginx配置
- Nginx 配置学习记录
- 记录 centos配置nginx
- nginx ofbiz 简单配置记录
- 记录nginx配置php7过程
- NGINX不记录某些日志的配置
- 08-nginx网站的配置过程记录
- nginx+tomcat绑定域名配置记录
- 记录一下nginx配置和重写开启
- Nginx配置过程中问题记录
- 记录配置nginx访问时过滤地址
- nginx学习记录02-配置说明
- Android中设置ListView内容刷新问题
- eclipse 常用插件 整理
- C#上机实验之题目四
- 【R机器学习笔记】XGBoost——XGBboost包
- Hibernate 学习笔记2
- Nginx配置记录
- 单链表的归并排序
- PAT_1032. Sharing(自己的代码最后一个case没过)
- Elasticearch索引mapping写入、查看、修改(head、kopf插件)
- POJ 1698 Alice's Chance 二分图多重匹配 网络最大流
- 1030. 完美数列(25)
- 第一章 USB Type C的基本原理(连载一)
- PL/SQL DeveloperZ中文乱码问题解决
- 冒泡排序-选择排序-快速排序(PHP实现)