Nginx 常用配置模板

Posted 现世安稳。

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx 常用配置模板相关的知识,希望对你有一定的参考价值。

user root  root;

worker_processes auto;
worker_rlimit_nofile 51200;

events {
        use epoll;
        worker_connections 51200;
        multi_accept on;
}

http {
        include mime.types;
        default_type  application/octet-stream;
        server_names_hash_bucket_size 128;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 1024m;

        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Headers X-Requested-With;
        add_header Access-Control-Allow-Methods GET,POST,OPTIONS;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 60;
        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6].";

        server_tokens off;
        access_log off;

        include vhost/*.conf;
}

  

server
    {
        listen 80;
        #listen [::]:80;
        server_name homework.wfkids.net;
        return 301 https://$server_name$request_uri;

        access_log logs/homework80.log;
    }
server
        {
            listen 443;
            #listen [::]:80;
            server_name homework.wfkids.net;
            index index.html index.htm index.php default.html default.htm default.php;
            root  /home/static/pages/homework.wfkids.net;

            #error_page   404   /404.html;


            #location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
            #{
            #    expires      30d;
            #}

            #location ~ .*.(js|css)?$
            #{
            #    expires      12h;
            #}

            location ~ /.
            {
                deny all;
            }

        location /course
        {
                proxy_pass http://homework.wfkids.net/course;
        }

            access_log  logs/homework443.log;
        }

  

server
    {
        listen 80;
        #listen [::]:80;
        server_name 1111.wfkids.net;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/1111.wfkids.net;

        include none.conf;
        #error_page   404   /404.html;
        include enable-php.conf;

        #location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
        #{
        #    expires      30d;
        #}

        #location ~ .*.(js|css)?$
        #{
        #    expires      12h;
        #}

        location ~ /.
        {
            deny all;
        }

        location /wfcm-api
        {
                proxy_pass http://wfnx.wfkids.net/wfcm-api;
        }

        location /record
        {
                proxy_pass http://release.console.wf.pcein.com:28080/record;
        }
        location /mmopen{
                proxy_pass http://thirdwx.qlogo.cn/mmopen;
        }
        access_log off;
    }
server
        {
            listen 443;
            #listen [::]:80;
            server_name 1111.wfkids.net;
            index index.html index.htm index.php default.html default.htm default.php;
            root  /home/wwwroot/1111.wfkids.net;

            include none.conf;
            #error_page   404   /404.html;
            include enable-php.conf;

            #location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
            #{
            #    expires      30d;
            #}

            #location ~ .*.(js|css)?$
            #{
            #    expires      12h;
            #}

            location ~ /.
            {
                deny all;
            }

        location /wfcm-api
        {
                proxy_pass http://wfnx.wfkids.net/wfcm-api/;
        }

        location /record
        {
                proxy_pass http://release.console.wf.pcein.com:28080/record;
        }
        location /mmopen{
                proxy_pass http://thirdwx.qlogo.cn/mmopen;
        }
            access_log off;
        }

  

以上是关于Nginx 常用配置模板的主要内容,如果未能解决你的问题,请参考以下文章

[AndroidStudio]_[初级]_[配置自动完成的代码片段]

C#常用代码片段备忘

Nginx 常用配置模板

linux学习:Nginx--常见功能配置片段与优化-06

VS Code配置snippets代码片段快速生成html模板,提高前端编写效率

nodejs常用代码片段