• Nginx 测试环境配置,留作笔记使用


    Nginx 测试环境配置,留做笔记

    以下全是配置文件的配置,如果有疑问还请移步Nginx官网参考官方文档。

    环境:

    [root@CentOS6-M01 conf]# cat /etc/redhat-release 
    CentOS release 6.9 (Final)
    [root@CentOS6-M01 conf]# uname -r
    2.6.32-696.18.7.el6.x86_64

    [root@CentOS6-M01 conf]# /usr/local/nginx/sbin/nginx -V
    nginx version: nginx/1.12.2
    built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
    built with OpenSSL 1.0.1e-fips 11 Feb 2013
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/nginx --with-stream --with-stream_ssl_module

    一、nginx.conf 配置

    user nginx;
    pid /usr/local/nginx/logs/nginx.pid;
    worker_processes auto;
    events {
        use epoll;
        worker_connections  2048;
        multi_accept on;
    }
    
    http {
        server_tokens   off;
        sendfile        on;
        tcp_nopush      on;
        tcp_nodelay     on;
    
        keepalive_timeout  65;
    
        client_header_timeout 10;
        client_body_timeout 10;
        
        reset_timedout_connection on;
        send_timeout 10;
    
        limit_conn_zone $binary_remote_addr zone=addr:5m;
        limit_conn addr 100;
    
        include         mime.types;
        default_type    application/octet-stream;
        charset         utf-8;
    
        gzip on;
        gzip_http_version 1.0;
        gzip_types      text/plain text/css application/json application/x-javascript text/xml application/xml
                        application/xml+rss text/javascript;
        gzip_min_length 1000;
        gzip_comp_level 4;
        gzip_vary       on;
    
        open_file_cache max=100000 inactive=20s;
        open_file_cache_min_uses 2;
        open_file_cache_valid 30s;
        open_file_cache_errors on;
    
    
        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       /usr/local/nginx/logs/access.log  main;
        access_log        off;
        error_log         /usr/local/nginx/logs/error.log crit;
    
    
    include /usr/local/nginx/conf/http_hosts/*.conf;
    }
    
    include /usr/local/nginx/conf/tcp_hosts/*.conf;

    二、http_hosts/test.conf 配置

        upstream tomcat_test {
            #ip_hash; #固定session
            server 127.0.0.1:8080;
        }
    
      server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
    
        location /tomcat {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://tomcat_test;
            proxy_redirect default;
            client_max_body_size 50m;
        }
    
    
        location /download {
            charset  utf-8;
            root /data/;
            #alias /data/download/;
    
            if ($request_filename ~* ^.*?.(txt)$){
            add_header Content-Disposition 'attachment';
            add_header Content-Type: 'APPLICATION/OCTET-STREAM';}
    
            autoindex on;
            autoindex_exact_size   off;
            autoindex_localtime    on;
            access_log  /usr/local/nginx/logs/download.log  main;
        }
    
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    
        access_log       /usr/local/nginx/logs/port-80-access.log  main;
      }

    三、 tcp_hosts/test.conf 配置

    stream {
        upstream tcp_template {
            server 127.0.0.1:8888;
        }
    
        server {
            listen                443 ssl;
            proxy_pass            tcp_template;
            #指定key 和 crt 地址
            #ssl_certificate       certs/my.crt;
            #ssl_certificate_key   certs/my.key;
            ssl_protocols         SSLv3 TLSv1 TLSv1.1 TLSv1.2;
            ssl_ciphers           HIGH:!aNULL:!MD5;
            ssl_session_cache     shared:SSL:20m;
            ssl_session_timeout   4h;
            ssl_handshake_timeout 30s;
        }
        server {
            listen                8889;
            proxy_pass            tcp_template;
           }
    
    }
  • 相关阅读:
    2019我学的东西
    jmeter之 java请求
    zookeeper简介和一些常用功能
    python 常见的一些高阶函数
    Jmeter之远程运行
    vue-cli eslint配置
    vue——element-ui项目中用如何点击导航菜单进行当前页面的router切换
    Vue 实现复制到粘贴板功能
    vscode 常用插件
    vue cli3中使用less
  • 原文地址:https://www.cnblogs.com/Star-Haitian/p/8385139.html
Copyright © 2020-2023  润新知