目的

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

目录结构

image.png

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镜像验证配置


simonbaker
256 声望2 粉丝

wx:毛毛虫的小小蜡笔