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 配置负载均衡
		为什么现在有非常多的聪明人都在致力于互联网? 最近在读埃隆·马斯克传记,他说「我认为现在有非常多的聪明人都在致力于互联网」. 仔细一想,好像真的是这样的. 我问了自己一个问题:如果你不敲代码了,你能做 ... 
随机推荐
- 小福bbs—项目系统设计与数据库设计
			这个作业属于哪个课程 班级链接 这个作业要求在哪里 作业要求的链接 团队名称 小福bbs 这个作业的目标 实现对校园论坛软件的制作,使其能够发布帖子,查看信息等 作业的正文 小福bbs--项目需求分析 ... 
- Django 测试开发3 数据模型models和admin管理工具
			参考:https://blog.csdn.net/weixin_44510615/article/details/89425412 1.Django模型字段常用类型: IntegerField : 整 ... 
- JMeter_控制器执行效果_给自己挖过的坑
			线程及循环设置: 数据文件中放在“循环控制器”中的执行效果:每条数据执行5次,取够50条数据时停止 简单逻辑控制器按下面的目录创建后,执行结果效果同上面循环控制器的执行效果 本来想规整下目录结构,结果 ... 
- 腾讯基于 Flink 的实时流计算平台演进之路
			https://mp.weixin.qq.com/s/MGnG_Mpf6CUQWLJHvmWqLA 
- AndroidStudio导入开源项目提示报错:Gradle sync failed: SSL peer shut down incorrectly
			问题描述: AndroidStudio导入开源项目提示报错:Gradle sync failed: SSL peer shut down incorrectly (1 m 12 s 92 ms) 解决 ... 
- vue 自定义全局方法
			import {myfun} from '../static/js/test.js' //se6的正确写法export default {methods:{ diyfun:function () { ... 
- Syste类
			System类的概述 System 类包含一些有用的类字段和方法.它不能被实例化. 成员方法 public static void gc() 运行垃圾回收器. public static void ... 
- java如何获取项目的工作目录
			package maptoxml; public class Tfff { public static void main(String[] args) { System.out.println(&q ... 
- Promise和Generator
			异同: 1.promise解决的是串行的嵌套异步问题. 2.yield把Generator Function切割为有多个出口的Generation. 3.Promise是社区的研发产物,yield是E ... 
- 【418】C语言ADT实现Quack(stack+queue)
			quack.h #include <stdio.h> #include <stdlib.h> #include <assert.h> typedef struct ... 
