Nginx配置相关

Posted by lizubing1992 on 04-26,2019

1.nginx.conf

user  nginx;
#Nginx进程,一般设置为和CPU核数一样
worker_processes  1;

#错误日志存放目录
error_log  /var/log/nginx/error.log warn;
#进程pid存放位置
pid        /var/run/nginx.pid;

events {
    worker_connections  1024; # 单个后台进程的最大并发数
}

http {

    include       /etc/nginx/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; #nginx访问日志存放位置

    sendfile        on; #开启高效传输模式
    #tcp_nopush     on; #减少网络报文段的数量

    keepalive_timeout  65; #保持连接的时间,也叫超时时间

    #gzip  on; #开启gzip压缩

    include /etc/nginx/conf.d/*.conf; #包含的子配置项位置和文件
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name www.kotm0065.com,kotm0065.com; 
    root /usr/share/nginx/html;

    include /etc/nginx/default.d/*.conf;
    location / {
    proxy_pass http://127.0.0.1:8080;
    }
    error_page 404 /404.html;
    location = /40x.html {
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}
}

2.conf.d/default.conf配置

server {
    listen        443;
    server_name   www.kotm0065.com kotm0065.com;
    index index.html index.htm default.html default.htm;
    root /mnt/www/www.lizubing.com/;
    ssl      on;

    ssl_certificate   /etc/nginx/1450921_www.kotm0065.com.pem;
    ssl_certificate_key  /etc/nginx/1450921_www.kotm0065.com.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
    ssl_prefer_server_ciphers on;

    location / {
       proxy_pass http://47.107.54.70:8080;
    }
    //配置静态资源
   location /html/ {
            root   /var/www/groupon/;
            autoindex on;
        }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

}
server{
    listen 80;
    server_name www.kotm0065.com;
    rewrite ^(.*) https://$server_name$1 permanent;
}

如果有什么问题可以查看/var/log/nginx/error.log


0评论