nginx作为web 虚拟主机配置文件模板

简介:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
1,默认
     server {
         listen       80;
         server_name  localhost;
         root html; 
 
         location / {
             index  index.html index.htm index.php;
         }
 
         #error_page  404              /404.html;
 
         error_page   500 502 503 504   /50x .html;
         location =  /50x .html {
             root   html;
         }
         location ~ .*\.(php|php5)?$
         {
             #fastcgi_pass  unix:/tmp/php-cgi.sock;
             fastcgi_pass  127.0.0.1:9000;
             fastcgi_index index.php;
             include fastcgi.conf;
         }
 
         #charset gbk;
         #limit_conn crawler 20;
         location ~ .*\.(ico|gif|jpg|jpeg|png|html|htm)$
         {
             expires 30d;
         }
 
         location ~ .*\.(css|js|txt|xml|swf|wav)$
         {
             expires 24h;
         }
         location ^~ /(svn|.svn|\. tar \.gz)
         {
             deny all;
         }
 
         access_log   /data0/logs/nginx/ $server_name.access.log  main;
     }
 
}
2,有rewrite
# cat app.test.com.conf 
server {
         listen       80;
         server_name  app. test .com;
         index index.html index.htm index.php;
         root  /data0/web_root/app . test .com /www ;
 
         location / {
             try_files $uri $uri/  /index .php$is_args$args;
         }
         include vhosts /rewrite_app .conf;
 
         #error_page  404              /404.html;
 
         error_page   500 502 503 504   /50x .html;
         location =  /50x .html {
             root   html;
         }
         location ~ \.php$ {
             include fastcgi.conf;
             #include fastcgi_params;
             fastcgi_pass   127.0.0.1:9000;
             #fastcgi_index index.php;
             try_files $uri =404;
         }
 
         #charset gbk;
         #limit_conn crawler 20;
         location ~ .*\.(ico|gif|jpg|jpeg|png|html|htm)$
         {
             expires 30d;
         }
 
         location ~ .*\.(css|js|txt|xml|swf|wav)$
         {
             expires 24h;
         }
         location ^~ /(svn|.svn|\. tar \.gz|\.git|\.ht|\.DS|\.pem)
         {
             deny all;
         }
 
         access_log   /data0/logs/nginx/app . test .com_access.log  main;
     }









本文转自 wpf926 51CTO博客,原文链接:http://blog.51cto.com/wupengfei/1958140,如需转载请自行联系原作者
目录
相关文章
|
17天前
|
应用服务中间件 网络安全 nginx
快速上手!使用Docker和Nginx部署Web服务的完美指南
快速上手!使用Docker和Nginx部署Web服务的完美指南
|
3天前
|
XML 开发框架 .NET
C#/ASP.NET应用程序配置文件app.config/web.config的增、删、改操作
C#/ASP.NET应用程序配置文件app.config/web.config的增、删、改操作
|
5天前
|
应用服务中间件 nginx
如何在树莓派部署Nginx并实现无公网ip远程访问内网制作的web网站
如何在树莓派部署Nginx并实现无公网ip远程访问内网制作的web网站
8 0
|
6天前
|
缓存 负载均衡 安全
深入探索Nginx高性能Web服务器配置与优化
【5月更文挑战第7天】本文深入探讨了Nginx的配置与优化,重点介绍了基础配置参数如`worker_processes`、`worker_connections`和`keepalive_timeout`,以及优化策略,包括使用epoll事件驱动模型、开启gzip压缩、启用缓存、负载均衡和安全配置。此外,还提到了性能调优工具,如ab、nginx-stats和nmon,以助于提升Nginx的性能和稳定性。
|
12天前
|
移动开发 JavaScript 前端开发
【专栏:HTML进阶篇】HTML模板与Web组件:可复用的网页元素
【4月更文挑战第30天】HTML模板和Web组件提升网页开发效率和可维护性。HTML模板,如<template>元素和服务器端模板引擎,用于创建可复用的HTML结构。Web组件是自定义的HTML元素,结合影子DOM和模板,实现封装的可重用组件。两者助力构建高效、现代的网页和网站。
|
13天前
|
Python
python web框架fastapi模板渲染--Jinja2使用技巧总结
python web框架fastapi模板渲染--Jinja2使用技巧总结
|
18天前
|
存储 NoSQL 应用服务中间件
Etcd+Confd实现Nginx配置文件自动管理
Etcd+Confd实现Nginx配置文件自动管理
|
18天前
|
负载均衡 监控 Unix
[AIGC] Nginx:一个高性能的 Web 服务器和反向代理
[AIGC] Nginx:一个高性能的 Web 服务器和反向代理
|
23天前
|
Java 应用服务中间件 PHP
Nginx配置文件解释
Nginx配置文件解释
18 1
|
1月前
|
域名解析 Ubuntu 应用服务中间件
Nginx实现虚拟主机
Nginx实现虚拟主机