Nginx server配置
项目一般都需要前后端的配置,用二级域名把它区分开:
首先在nginx.conf;里面加一句话:
http{
#这里面有很多其他的配置 如:gzip FastCGI等等
include vhosts/*.host;
}
文件夹自己定义 反正引进去就好了:
cd yourdirname 创建一个文件 ,命名为:default.host,写入下面的代码
server {
listen default;
rewrite ^(.*) http://www.xuesong0323.cn permanent;
}
这里创建server的时候 在监听80端口的后面加了一个default,目的是为了一个默认重定向
每一个二级域名添加进去的时候都推荐新建一个文件,这样方便以后管理。下面举个栗子:
文件名:www.host
server {
listen ;
server_name www.xuesong0323.cn;
error_page = http://www.xuesong0323.cn/;
location ~ ^/www/.*\.html$ {
proxy_redirect off;
proxy_set_header Host pms.dohohome.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://...:;
}
location / {
root your root dirname; #你的项目入口绝对路径
index index.html index.php index.htm;#入口可以解析的文件类型 如果有需要,可以吧index.html/php/htm改成自己需要的文件名和类型
}
include rewrite/www.conf; #这里我是引入了www的路由重写规则,具体需要看自己的项目需求
location ~*\.php$ {
limit_conn connlimitzone ;
limit_req zone=rqlimitzone burst= nodelay;
root /apps/web/doho/shop_fend/public/; #项目入口绝对路径
#try_files $uri=;
fastcgi_pass ...:; #php-fpm要用的 不用管
fastcgi_index index.php; #fastcgi_index参数,具体解释见上一篇
fastcgi_param SCRIPT_FILENAME your root dirname$fastcgi_script_name;
include fastcgi_params;
}
location ~* .(htaccess)$ {rewrite ^/(.*) /index.php last;}
access_log /var/log/nginx/www.access.log main; #日志记录
}
还有一个配置其他端口的:(其实都一样的)8081.host
server {
listen ;
server_name www.xuesong0323.cn;
#access_log logs/host.access.log main;
location / {
root /home/***/;#向配哪里配哪里,后面一致就好了
index index.html index.php .php .html;
}
error_page /50x.html;#错误页面
location = /50x.html {
#错误页面路径
root /home/***/;#这个一般不会改,除非你觉得自己写的的比较好看= =,我这个是改过的
}
location ~ \.php$ {
root /home/***/;
fastcgi_pass ...:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Nginx server配置的更多相关文章
- NGINX server配置中if的用法
server的配置以php为例,如下: 1 server{ 2 root /var/webproject/www/mytools-php; 3 index index.html index.php; ...
- Nginx Server 配置
http { include mime.types; // 主模块:实现对配置文件包含的文件设定,可以减少主配置文件的复杂度: default_type application/octet-strea ...
- 在nginx中配置如何防止直接用ip访问服务器web server及server_name特性讲解
看了很多nginx的配置,好像都忽略了ip直接访问web的问题,不利于SEO优化,所以我们希望可以避免直接用IP访问网站,而是域名访问,具体怎么做呢,看下面. 官方文档中提供的方法: If you d ...
- 配置 nginx server 出现nginx: [emerg] "root" directive is duplicate in /etc/nginx/server/blogs.conf:7
在配置nginx 虚拟机时,执行 sudo /usr/sbin/nginx -t 报下面的错误: nginx: [emerg] nginx: configuration file /etc/nginx ...
- windows server,nginx安装,配置,运行nodeJS后端的web项目的实现,以及错误分析及解决方法
一.安装nginx 下载windows版nginx (http://nginx.org/download/nginx-1.12.2.zip),之后解压到需要放置的位置(C:\nginx) 二.将Ngi ...
- nginx的开机自启、server命令启动、nginx.conf配置
1.将Nginx设置为开机自动启动 a.当上面6步完成之后,说明安装已经完全成功了,但是每次开机我们面临的一个问题,就是每次都要执行命令(1: cd /usr/local/nginx/sbin/ ...
- Nginx httpS server配置
Nginx httpS 配置 配置同时支持http和httpS协议: server { listen ; #backlog:每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包 ...
- 如何在Nginx下配置PHP程序环境
1.nginx与PHP的关系 首先来看nginx与php的关系, FastCGI的关系(而不是像apache那样安装成nginx的模块) FastCGI的意思是, 快速的通用网关接口:CGI Comm ...
- 从零开始学 Java - CentOS 下 Nginx + Tomcat 配置负载均衡
为什么现在有非常多的聪明人都在致力于互联网? 最近在读埃隆·马斯克传记,他说「我认为现在有非常多的聪明人都在致力于互联网」. 仔细一想,好像真的是这样的. 我问了自己一个问题:如果你不敲代码了,你能做 ...
随机推荐
- [转]Python3之max key参数学习记录
Python3之max key参数学习记录 转自https://www.cnblogs.com/zhangwei22/p/9892422.html 今天用Python写脚本,想要实现这样的功能:对于给 ...
- 关于linux下的系统存储管理
https://blog.csdn.net/aaaaaab_/article/details/80159871 //查看当前系统磁盘使用空间 df -h //查看当前目录文件占用空间大小 du -sh ...
- vue-cli及vue-router
1.单文件组件 (1)问题: 使用 Vue.component 来定义全局组件,紧接着用 new Vue({ el: ‘#container ‘}) 在每个页面内指定一个容器元素.当在更复杂的项 ...
- MyBatis 插件之拦截器(Interceptor)
参考 https://blog.csdn.net/weixin_39494923/article/details/91534658 //项目实际使用 就是在你进行数据库操作时,进行数据的第二次封装 ...
- 简易的CRM系统案例之SpringMVC+JSP+MySQL+myBatis框架版本
主要对上一版DAO框架的替换hibernate变成myBatis 简易的CRM系统案例之SpringMVC+JSP+MySQL+hibernate框架版本 src/mybatis.xml <?x ...
- osg RTT 多相机-局部放大镜
#ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include<iostream> #include <osgV ...
- java获取properties配置文件中某个属性最简单方法
假如我想获取src目录下sysConfig.properties中的uploadpath属性的值 方法如下所示: private static final ResourceBundle bundle ...
- 123457123456#0#-----com.threeapp.BabyLeaningEnglish01----精品儿童学英语
com.threeapp.BabyLeaningEnglish01----精品儿童学英语
- 关于Selenium remote模式分布式执行UI自动化测试必定面临的性能问题
1.大部分自动化测试人员都是在本地执行UI自动化测试,也就是代码和浏览器必须在同一台机器上,这样的的缺陷很多,无法多任务并发执行UI自动化测试用例,效率极低 2.正是如此,Selenium 的remo ...
- 【Leetcode_easy】784. Letter Case Permutation
problem 784. Letter Case Permutation 参考 1. Leetcode_easy_784. Letter Case Permutation; 2. Grandyang; ...