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;
#报错日志
error_log logs/error.log
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name www.hool.com;
location / {
root /mnt/win/tp5/public;
index index.php index.html;
#如果资源不存在 那么交给php处理
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1;
}
server {
listen 80;
server_name 8082.max.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://tomcatserver2;
index index.html index.htm;
}
}
# \. 意是将.转义 凡是访问域名www.hool.com/xxx.php的就反向代理到www.hook.com:8088上去
location ~ \.php$ {
# proxy_pass http://www.hook.com:8088;
#有效期1天
#expire 1d
}
# 凡是访问域名www.hool.com/org的就反向代理到www.mool.com:8088上去
location org/ {
# proxy_pass http://www.mool.com:8088;
#有效期1天 可加可不加
#expire 1d
}
location org/bid/public/static {
# proxy_pass http://www.mool.com:8088/org/bid/pubic/static/;
#有效期1天 可加可不加
#expire 1d
}
}
}
注意访问代理过去的静态资源,要写好路径,不然到分发路由的机器上找资源(排除在分发的服务器上弄全局静态资源)。
#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 /mnt/win/NetbeanWorkspace/tp5/public;
index index.html index.php index.htm;
}
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1;
}
#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
#
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php {
root /mnt/win/NetbeanWorkspace/tp5/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAM /mnt/win/NetbeanWorkspace/tp5/public$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;
}
# 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;
# }
#}
}
网友评论