nginx常用配置和nginx镜像验证配置

目的

总结项目中常用的nginx配置,然后通过docker构建一个nginx镜像来快速使用和验证。

目录结构

 

nginx配置

nginx.conf文件:

user nginx;
worker_processes auto;

error_log  /var/log/nginx/error.log  notice;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

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

    sendfile on;
    
    keepalive_timeout 75;

    server_tokens off;

    autoindex off;

    charset utf-8;

    # 开启gzip压缩
    gzip on;
    
    ......

详情: nginx常用配置和nginx镜像验证配置

 

posted @ 2023-09-13 17:54  simonbaker  阅读(68)  评论(0编辑  收藏  举报