zoukankan      html  css  js  c++  java
  • Nginx配置(*,跨域,限制访问评率)

    Nginx 配置

    分前端(纯静态)直接放到nginx中

    后端接口

    后端文件系统

    完整的配置如下:

    user  nginx;
    worker_processes  1;
    
    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
    
            gzip  on;
            gzip_min_length 1k;
            gzip_comp_level 6;
            gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
            gzip_disable "MSIE [1-6].";
            gzip_vary 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  /var/log/nginx/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        keepalive_timeout  65;
    
            limit_req_zone $binary_remote_addr zone=allips:10m rate=150r/s;
        
            server {
              client_max_body_size 50m; 
                     listen    80;
                     add_header Access-Control-Allow-Origin *;
                  add_header Access-Control-Allow-Methods 'GET,POST';
                  add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';  
          # 文件系统
            location /file_system {
           limit_req zone=allips burst=5 nodelay;
               proxy_pass http://127.0.0.1:19527;
            }
            # 后台接口
           location /api {
           limit_req zone=allips burst=5 nodelay;
               proxy_pass http://127.0.0.1:10086;
           }
           #前端页面
           location / {
           limit_req zone=allips burst=5 nodelay;
               root /crowdsourcing/front/; 
               index index.html;
           }
        
        }
        include /etc/nginx/conf.d/*.conf;
    }

  • 相关阅读:
    PHP 页面编码声明方法详解(header或meta)
    淘客部分功能实现源码
    CSS3动画效果应用
    JavaScript之Tab标签(原始版)
    JavaScript之淡入淡出
    关于响应式布局
    深入理解 SVG 系列(一) —— SVG 基础
    面试题
    随记
    一道经典面试题-----setTimeout(function(){},0)
  • 原文地址:https://www.cnblogs.com/DevinZhang1990/p/12795543.html
Copyright © 2011-2022 走看看