nginx 簡單配置
阿新 • • 發佈:2018-06-03
RM script php pem TP nbsp IT usr deny https的配置方法
#這個是接口文檔的----------------------------------
server {
#偵聽80端口
listen 80;
#定義使用 www.nginx.cn訪問
server_name tapi.***.net;
#定義服務器的默認網站根目錄位置
root /usr/share/nginx/html/api/public;
#設定本虛擬主機的訪問日誌
# access_log logs/nginx.access.log main;
#默認請求
location / {
root
/usr/share/nginx/html/api/public;
index
index.html index.htm index.php;
#去除index.php用的
#方法1----
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
#如果文件不存在則嘗試TP解析 (方法2)
# try_files $uri /index.php$uri;
}
# 定義錯誤提示頁面
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# #靜態文件,nginx自己處理
# location ~ ^/(images|javascript|js|css|flash|media|static)/ {
# #過期30天,靜態文件不怎麽更新,過期可以設大一點,
# #如果頻繁更新,則可以設置得小一點。
# expires 30d;
# }
#PHP 腳本請求全部轉發到 FastCGI處理. 使用FastCGI默認配置.
location ~ \.php {
root /usr/share/nginx/html/api/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
# set $path_info "";
# set $real_script_name $fastcgi_script_name;
# if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
# set $real_script_name $1;
# set $path_info $2;
# }
# fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
# fastcgi_param SCRIPT_NAME $real_script_name;
# fastcgi_param PATH_INFO $path_info;
# #如果文件不存在則嘗試TP解析 (方法2) # # try_files $uri /index.php$uri; # } # # 定義錯誤提示頁面 # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # # #靜態文件,nginx自己處理 # # location ~ ^/(images|javascript|js|css|flash|media|static)/ { # # #過期30天,靜態文件不怎麽更新,過期可以設大一點, # # #如果頻繁更新,則可以設置得小一點。 # # expires 30d; # # } # #PHP 腳本請求全部轉發到 FastCGI處理. 使用FastCGI默認配置. # location ~ \.php { # root /usr/share/nginx/html/index/public; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # include fastcgi_params; # # set $path_info ""; # # set $real_script_name $fastcgi_script_name; # # if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { # # set $real_script_name $1; # # set $path_info $2; # # } # # fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; # # fastcgi_param SCRIPT_NAME $real_script_name; # # fastcgi_param PATH_INFO $path_info;
# fastcgi_split_path_info ^(.+\.php)(/.*)$; # fastcgi_param PATH_INFO $fastcgi_path_info; # } # #禁止訪問 .htxxx 文件 # location ~ /.ht { # deny all; # } # }
rewrite ^(.*) https://$server_name$1 permanent; } #微信項目 https配置 server {
listen 443 ssl; server_name tapi.m***.net;
ssl_certificate /etc/nginx/ssl_key/2147197624dd932.pem; ssl_certificate_key /etc/nginx/ssl_key/2147197dd410932.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on;
fastcgi_split_path_info ^(.+\.php)(/.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; } #禁止訪問 .htxxx 文件 location ~ /.ht { deny all; } } 普通的80端口配置方法—————————— # #這個是接口文檔的---------------------------------- # server { # #偵聽80端口 # listen 80; # #定義使用 www.nginx.cn訪問 # server_name test.m***.net; # #定義服務器的默認網站根目錄位置 # root /usr/share/nginx/html/index/public; # #設定本虛擬主機的訪問日誌 # # access_log logs/nginx.access.log main; # #默認請求 # location / { # root # /usr/share/nginx/html/index/public; # index # index.html index.htm index.php; # #去除index.php用的 # #方法1---- # if (!-e $request_filename) { # rewrite ^(.*)$ /index.php?s=/$1 last; # break; # }
# #如果文件不存在則嘗試TP解析 (方法2) # # try_files $uri /index.php$uri; # } # # 定義錯誤提示頁面 # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # # #靜態文件,nginx自己處理 # # location ~ ^/(images|javascript|js|css|flash|media|static)/ { # # #過期30天,靜態文件不怎麽更新,過期可以設大一點, # # #如果頻繁更新,則可以設置得小一點。 # # expires 30d; # # } # #PHP 腳本請求全部轉發到 FastCGI處理. 使用FastCGI默認配置. # location ~ \.php { # root /usr/share/nginx/html/index/public; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # include fastcgi_params; # # set $path_info ""; # # set $real_script_name $fastcgi_script_name; # # if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { # # set $real_script_name $1; # # set $path_info $2; # # } # # fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; # # fastcgi_param SCRIPT_NAME $real_script_name; # # fastcgi_param PATH_INFO $path_info;
# fastcgi_split_path_info ^(.+\.php)(/.*)$; # fastcgi_param PATH_INFO $fastcgi_path_info; # } # #禁止訪問 .htxxx 文件 # location ~ /.ht { # deny all; # } # }
nginx 簡單配置