前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >05-Nginx配置文件详解

05-Nginx配置文件详解

作者头像
彼岸舞
发布2022-09-13 09:16:50
2860
发布2022-09-13 09:16:50
举报
文章被收录于专栏:java开发的那点事

nginx.conf

配置文件结构

配置文件详解

代码语言:javascript
复制
# 默认的工作进程 是由nobody用户去执行的, master由root执行
#user  nobody;
# 工作进程的数量 默认为1
worker_processes  2;

# 用于配置日志的输出位置, 可以区分级别输出到不同的文件, 级别从低到高为
# debug info notice warn error crit
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

# 指定进程pid的位置
#pid        logs/nginx.pid;

# 事件
events {
    # 默认采用epoll
    use epoll;
    # 工作进程的最大客户端连接数
    worker_connections  1024;
}

# http协议
http {
    # 导入一个types文件, 里面基本都是请求类型
    include       mime.types;
    # 默认type类型
    default_type  application/octet-stream;

    # 日志格式化
    #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  logs/access.log  main;

    # 提升文件传输效率
    sendfile        on;
    # 当数据包累计到一定大小才进行发送,配合sendfile使用
    #tcp_nopush     on;

    # 客户端连接服务器的超时时间(秒)
    #keepalive_timeout  0;
    keepalive_timeout  65;

    # 输出数据压缩,压缩数据内容, 提高传输速度
    #gzip  on;

    # 服务器
    server {
        # 监听端口
        listen       80;
        # 服务地址
        server_name  localhost;

        # 字符集
        #charset koi8-r;

        # 该服务器的日志位置
        #access_log  logs/host.access.log  main;

        # 路由表
        location / {
            root   html;
            index  index.html index.htm;
        }

        # 错误页面 404 状态时跳转到/404.html
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        # 500 502 503 504 状态时跳转到/50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        # 匹配到.php结尾的请求代理到 http://127.0.0.1
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        # 
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-09-06,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • nginx.conf
    • 配置文件结构
      • 配置文件详解
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档