一、前提条件
<font size=4>1、Nginx 编译安装
2、Nginx 中文文档
二、配置规范
2.1.简化主配置文件
>1.主配置尽量减少配置,进行配置拆分 2.避免主配置臃肿复杂,难于维护 3.避免主配置有误,影响全局 4.采用配置文件加载,简单清晰2.2.配置分类存放
>1.目录、文件命名采用业务相关信息 2.每个业务独立配置文件 3.相同、类似业务配置进行归类存放三、配置案例
3.1.Nginx.conf(主配置文件)
``` user nginx; worker_processes 8;error_log logs/error.log;
pid logs/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
add_header X-Frame-Options SAMEORIGIN;
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"';
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
server_names_hash_bucket_size 128;
client_header_buffer_size 2k;
large_client_header_buffers 4 4k;
client_max_body_size 8000m;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 16k;
fastcgi_buffers 16 16k;
fastcgi_busy_buffers_size 16k;
fastcgi_temp_file_write_size 16k;
open_file_cache max=204800 inactive=20s;
open_file_cache_min_uses 1;
open_file_cache_valid 30s;
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;
include /data/nginx/conf/conf_admin/*.conf;
include /data/nginx/conf/conf_conf/*.conf;
}
</font>
### 3.2.子配置目录
<font size=4>
mkdir -p /data/nginx/conf/{conf_admin,conf_conf}
</font>
### 3.3.子配置文件
<font size=4>
>****配置文件:**** /data/nginx/conf/conf_admin/80_admin.conf
server {
listen 80;
server_name ywwiki.linkdood.cn;
access_log /data/Yunwei/nginx/logs/wiki_access.log main;
location / {
proxy_pass http://172.16.8.184:18090;
}
}
>****配置文件:**** /data/nginx/conf/conf_conf/443_conf.conf
server {
listen 443;
server_name show178.linkdood.cn;
access_log /data/linkdood/logs/nginx/443_access.log main;
add_header X-Frame-Options "SAMEORIGIN";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Scheme $scheme;
aio threads;
ssl on;
ssl_certificate /data/linkdood/im/conf/standard.crt;
ssl_certificate_key /data/linkdood/im/conf/standard.key;
ssl_session_cache shared:SSL:250m;
ssl_session_timeout 30m;
location / {
proxy_pass http://172.16.8.184:18090;
}
}
</font>
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于