一个实用的nginx配置
2017-06-05 00:00
162 查看
记录一下内容,以备查阅!
注:转发的时候,是以包的名字区分的。
1、httpd.conf
server {
listen 8081;
server_name localhost;
#charset koi8-r;
access_log /home/log/localhost.access.log ;
error_log /home/log/localhost.error.log ;
location ~ ^/guahao{
proxy_set_header Host guahao.z.com;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:81; }
location ~ ^/hos{
proxy_set_header Host hos.guahao.z.com;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:81; }
location ~ ^/admin{
proxy_set_header Host ghadmin.z.com;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:81; }
location ~ ^/item{
proxy_pass http://127.0.0.1:8090; }
# location ~ !^/(guahao|hos|admin){
# proxy_pass http://127.0.0.1:8082; # }
}
2、guahao.z.com.conf
server {
listen 81;
root /**/**/**/guahao.z.com/web/;
server_name guahao.z.com;
default_type 'text/html';
#charset GBK;
access_log /home/log/guahao.z.com.access.log ;
error_log /home/log/guahao.z.com.error.log ;
location / {
index index.html index.htm index.php;
}
#error_page 404 /404.html;
rewrite ^/guahao/(.*) /$1 last;
location ~ .*\.php {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
3、hos.guahao.z.com.conf
server {
listen 81;
root /**/**/**/hos.guahao.z.com/;
server_name hos.guahao.z.com;
default_type 'text/html';
#charset GBK;
access_log /home/log/hos.guahao.z.com.access.log ;
error_log /home/log/hos.guahao.z.com.error.log ;
location / {
index index.html index.htm index.php;
}
#error_page 404 /404.html;
rewrite ^/hos/(.*) /$1 last;
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
4、ghadmin.z.com.conf
server {
listen 81;
root /**/**/**/ghadmin.z.com/admin/;
server_name ghadmin.z.com;
default_type 'text/html';
#charset GBK;
access_log /home/log/ghadmin.z.com.access.log ;
error_log /home/log/ghadmin.z.com.error.log ;
location / {
index index.html index.htm index.php;
}
#error_page 404 /404.html;
rewrite ^/admin/(.*) /$1 last;
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
注:转发的时候,是以包的名字区分的。
1、httpd.conf
server {
listen 8081;
server_name localhost;
#charset koi8-r;
access_log /home/log/localhost.access.log ;
error_log /home/log/localhost.error.log ;
location ~ ^/guahao{
proxy_set_header Host guahao.z.com;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:81; }
location ~ ^/hos{
proxy_set_header Host hos.guahao.z.com;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:81; }
location ~ ^/admin{
proxy_set_header Host ghadmin.z.com;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:81; }
location ~ ^/item{
proxy_pass http://127.0.0.1:8090; }
# location ~ !^/(guahao|hos|admin){
# proxy_pass http://127.0.0.1:8082; # }
}
2、guahao.z.com.conf
server {
listen 81;
root /**/**/**/guahao.z.com/web/;
server_name guahao.z.com;
default_type 'text/html';
#charset GBK;
access_log /home/log/guahao.z.com.access.log ;
error_log /home/log/guahao.z.com.error.log ;
location / {
index index.html index.htm index.php;
}
#error_page 404 /404.html;
rewrite ^/guahao/(.*) /$1 last;
location ~ .*\.php {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
3、hos.guahao.z.com.conf
server {
listen 81;
root /**/**/**/hos.guahao.z.com/;
server_name hos.guahao.z.com;
default_type 'text/html';
#charset GBK;
access_log /home/log/hos.guahao.z.com.access.log ;
error_log /home/log/hos.guahao.z.com.error.log ;
location / {
index index.html index.htm index.php;
}
#error_page 404 /404.html;
rewrite ^/hos/(.*) /$1 last;
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
4、ghadmin.z.com.conf
server {
listen 81;
root /**/**/**/ghadmin.z.com/admin/;
server_name ghadmin.z.com;
default_type 'text/html';
#charset GBK;
access_log /home/log/ghadmin.z.com.access.log ;
error_log /home/log/ghadmin.z.com.error.log ;
location / {
index index.html index.htm index.php;
}
#error_page 404 /404.html;
rewrite ^/admin/(.*) /$1 last;
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
相关文章推荐
- 一个完整的nginx配置文件范例参考(含负载均衡)
- 【nginx】配置nginx支持ssl sni (一个IP绑定多个证书)
- nginx实用配置
- 一个完整的nginx生产配置示例
- nginx 同一个IP上配置多个HTTPS主机
- 一个简单的nginx加多个fastcgi的负载均衡配置过程
- LVS+Keepalived+Nginx+Tomcat高可用负载均衡集群配置(DR模式,一个VIP,多个端口)
- 一个等号引发的血案(谈Nginx正确的404配置)
- Nginx实现多个站点使用一个端口(配置Nginx的虚拟主机)
- NGINX 配置的一个坑,proxy_set_header 中携带下划线
- 配置nginx与wordpress碰到的一个偱环重定向问题
- Nginx配置实用密码访问网站的方法
- 网上找的一个nginx的url重写配置
- 解决nginx作为前端代理默认访问一个80端口虚拟主机配置问题
- 简单实用nginx 配置 本机 虚拟主机 windows 下的。
- 用Perl写一个读取nginx配置文件到csv,实现域名与IP对应的实用程序
- Nginx一个IP配置多个主机
- 一个nginx配置例子
- 给Nginx配置一个自签名的SSL证书
- nginx 同一个IP上配置多个HTTPS主机