Nginx更改conf配置文件的代碼詳解
安裝Nginx默認(rèn)的配置文件路徑:
/usr/local/nginx/conf/nginx.conf
默認(rèn)的ngnix.conf:
user nobody;
worker_processes 8;
pid log/nginx.pid;
events {
use epoll;
worker_connections 100000;
}
worker_rlimit_nofile 100000;
http {
include mime.types;
default_type application/octet-stream;
server_tokens 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 on;
keepalive_timeout 0;
fastcgi_connect_timeout 30;
fastcgi_send_timeout 30;
fastcgi_read_timeout 30;
fastcgi_buffer_size 1k;
fastcgi_buffering off;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
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 text/javascript;
gzip_vary on;
charset utf-8;
access_log off;
log_not_found off;
error_page 400 403 405 408 /40x.html ;
error_page 500 502 503 504 /50x.html ;
server {
listen 80;
server_name aaicourt.qcloud.com;
client_max_body_size 100M;
root /data/qcloud/proxy/www;
access_log /data/qcloud/proxy/log/weblog/access.log;
error_log /data/qcloud/proxy/log/weblog/error.log;
location / {
index index.php index.html index.htm;
if (-d $request_filename) {
rewrite ^(/.*[^/])$ $1/index.php;
}
}
rewrite ^/([a-zA-Z0-9]+)$ / last;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ voice.cgi {
fastcgi_pass 127.0.0.1:3001;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ register.cgi {
fastcgi_pass 127.0.0.1:3002;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ inner.cgi {
fastcgi_pass 127.0.0.1:3003;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SERVER_NAME $http_host;
include fastcgi_params;
fastcgi_ignore_client_abort on;
fastcgi_connect_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
}
location ~ /.svn/ {
deny all;
}
}
}
我們現(xiàn)在開(kāi)始更改,使此配置文件與更多的配置文件相關(guān)聯(lián)。
主要是跟最后面的include有關(guān),情況nginx.conf
user root;
worker_processes auto;
error_log /var/nginx/logs/error.log;
pid ./nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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 /var/nginx/logs/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;
include /usr/local/nginx/conf/conf.d/*.conf;
}
其余的conf,我隨便舉個(gè)例子:
/usr/local/nginx/conf/conf.d
server {
listen 80 default;
server_name localhost;
root /var/www/html/roboot/public/;
index index.html index.php index.htm;
access_log /var/log/nginx/ac_bot.log;
error_log /var/log/nginx/err_bot.log;
# set expiration of assets to MAX for caching
location ~* \.(ico|css|js|gif|jpe?g|png|ogg|ogv|svg|svgz|eot|otf|woff)(\?.+)?$ {
expires max;
log_not_found off;
}
server_tokens off;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
index index.php index.html;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php last;
}
}
}
到此這篇關(guān)于Nginx更改conf配置文件的代碼詳解的文章就介紹到這了,更多相關(guān)Nginx更改conf配置文件內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
nginx禁止某個(gè)IP訪問(wèn)站點(diǎn)的設(shè)置方法
近期發(fā)現(xiàn)博客遭到某些人的惡意灌水,頻繁地利用發(fā)帖機(jī)器人發(fā)表評(píng)論,給博客的管理帶來(lái)諸多不便,搜索了一下資料,可以利用nginx的ngx_http_access_module 模塊設(shè)置允許/禁止哪些ip或ip段訪問(wèn)站點(diǎn)。2010-12-12
Nginx靜態(tài)文件響應(yīng)POST請(qǐng)求 提示405錯(cuò)誤的解決方法
Apache、IIS、nginx等絕大多數(shù)web服務(wù)器,都不允許靜態(tài)文件響應(yīng)POST請(qǐng)求,否則會(huì)返回“HTTP/1.1 405 Method not allowed”錯(cuò)誤2013-04-04
Nginx基礎(chǔ)學(xué)習(xí)之realip模塊的使用方法
這篇文章主要給大家介紹了關(guān)于Nginx基礎(chǔ)學(xué)習(xí)之realip模塊使用的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Nginx具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06
nginx?status配置及參數(shù)配置小結(jié)
本文主要介紹了nginx?status配置及參數(shù)配置,其實(shí)要監(jiān)控Nginx的狀態(tài)非常簡(jiǎn)單,它內(nèi)建了一個(gè)狀態(tài)頁(yè),只需修改Nginx配置啟用Status即可,感興趣的可以了解一下2024-04-04
解讀nginx反向代理location和proxy_pass的映射關(guān)系
這篇文章主要介紹了解讀nginx反向代理location和proxy_pass的映射關(guān)系,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-01-01
Nginx配置帶SSL認(rèn)證的轉(zhuǎn)發(fā)方式 (HTTPS請(qǐng)求)
本文詳細(xì)介紹了如何在Windows系統(tǒng)上安裝和配置Nginx以支持HTTPS,首先,下載并解壓Nginx和OpenSSL,并配置環(huán)境變量,然后,生成SSL證書(shū)和密鑰文件,并在Nginx配置文件中啟用SSL,最后,啟動(dòng)Nginx并訪問(wèn)配置的HTTPS路徑以驗(yàn)證配置是否成功2026-01-01
Nginx中定義404頁(yè)面并且返回404狀態(tài)碼的正確方法
這篇文章主要介紹了Nginx中定義404頁(yè)面并且返回404狀態(tài)碼的正確方法,本文在一次AJAX調(diào)用時(shí)發(fā)現(xiàn)了這個(gè)問(wèn)題,服務(wù)器返回了一個(gè)404頁(yè)頁(yè)但沒(méi)有返回404狀態(tài)碼,需要的朋友可以參考下2014-08-08
Nginx記錄分析響應(yīng)慢的請(qǐng)求及替換網(wǎng)站響應(yīng)內(nèi)容的配置
這篇文章主要介紹了Nginx記錄分析響應(yīng)慢的請(qǐng)求及替換網(wǎng)站響應(yīng)內(nèi)容的配置,分別用到了ngx_http_log_request_speed模塊和ngx_http_sub_module模塊,需要的朋友可以參考下2016-01-01
使用nginx方式實(shí)現(xiàn)http轉(zhuǎn)換為https的示例代碼
這篇文章主要介紹了使用nginx方式實(shí)現(xiàn)http轉(zhuǎn)換為https的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09

