首页 > 系统相关 >Nginx--引用多配置文件

Nginx--引用多配置文件

时间:2024-02-05 11:04:03浏览次数:29  
标签:log 配置文件 nginx -- etc Nginx html conf include

在nginx.conf的http模块,include 指定某个目录下的*.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
    server {
        listen       8080 default_server;
        listen       [::]:8080 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
    include             sites-enabled/*.conf;
}

 

创建sites-enabled目录,编写配置文件

mkdir /etc/nginx/sites-enabled
touch /etc/nginx/sites-enabled/test1.conf

 

编写sever模块创建多个虚拟主机(注意root目录及日志文件路径)

Nginx--引用多配置文件_html

 



标签:log,配置文件,nginx,--,etc,Nginx,html,conf,include
From: https://blog.51cto.com/u_16558404/9601628

相关文章

  • Nginx--平滑升级
    在不中断服务的情况下,新的请求也不会丢失,使用新的nginx可执行程序替换旧的 1 查看老版本的编译选项[root@localhost~]#nginx-Vnginxversion:nginx/1.16.0builtbygcc4.8.520150623(RedHat4.8.5-44)(GCC)builtwithOpenSSL1.0.2k-fips26Jan2017TLSSNI......
  • Nginx--upstream健康检查
    nginx判断节点失效状态:Nginx默认判断失败节点状态以connectrefuse和timeout状态为准,不以HTTP错误状态进行判断失败,因为HTTP只要能返回状态说明该节点还可以正常连接,所以nginx判断其还是存活状态;除非添加了proxy_next_upstream指令设置对404、502、503、504、500和timeout......
  • DNS--安装&&配置文件
    1 下载#下载服务yum-yinstallbind#下载解析工具yum-yinstallbind-utils 2 配置文件主配置文件/etc/named.conf区配置文件/var/named/配置文件模板/usr/share/doc/bind-9.8.2/sample 3 协议及端口TCP53主要用于主从同步,需要的是可靠的数......
  • DNS--简介&&解析过程
    1 功能将域名解析为IP地址基本解决IP难于记忆的问题也可以将IP地址解析为域名 2 域名由一连串用点(.)分隔的字符串组成的标识计算机在网络中的电子方位的 3 存储位置linux/etc/hostswindowsC:\WUNDOWS\system32\drivers\etc\hosts 4 全质量域名/完全域名......
  • DNS--解析
    一 正向解析(域名解析成ip)1 修改主配置文件[root@localhost~]#cp-p/etc/named.conf/etc/named.conf.bak[root@localhost~]#vim/etc/named.confoptions{listen-onport53{any;};#默认127.0.0.1,会导致其他人无法访问DNS服务器,需修改allow-qu......
  • DNS--智能地址解析(view视图)
    域名:xinenhui.comDNS服务器:192.168.198.128DNS1:192.168.198.129DNS2:192.168.198.146 1 简介使客户端就近访问DNS服务器来加速用户的访问速度 提高客户端体验不同的客户端使用同一个DNS服务器解析同一个域名得到不同的IP 2 修改主配置文件 设置view[root@localhost~]#vi......
  • DNS--主从
    操作系统:centos7.8DNS-master:192.168.198.128DNS-slave:192.168.198.129 一主从同步过程master修改完成重启后将传送notify给所有slaveslave将查询master的SOA记录master收到请求后将SOA记录发送给slaveslave收到后同时对比查询结果中的serial值,大于将发送zonetransfer......
  • 如何在Python中保留异常装饰器的堆栈跟踪
    异常装饰器是一种通过装饰器(Decorator)机制来捕获和处理函数中异常的技术。当函数中发生异常时,装饰器可以捕获异常并进行处理,也可以记录异常信息或进行其他操作。堆栈跟踪(StackTrace)是指在发生异常时,系统会输出一个包含异常信息和函数调用链的信息。对于经常使用python做爬虫来说,这......
  • 获取请求ip
    publicstaticStringgetUserIp(HttpServletRequestrequest){if(ObjectUtils.isEmpty(request)){returnnull;}//获取客户端前台IP进行解析StringuserIp=request.getHeader("x-forwarded-for");if(userIp==null||userIp.isEmpty......
  • mysql如何实现左连接、右连接
    学生表 students学生ID学生姓名1张三2李四3王五4小六5小七成绩表 grades学生ID课程学生成绩1数学862语文793数学914英语881、查询所有学生的id、姓名、成绩用左连接可以实现:SELECTstudents.学生ID,students.学生姓名,grades.成绩FROMstudentsLEFTJOINgradesONstudents.......