zoukankan      html  css  js  c++  java
  • nginx配置

    前后端分离开发,当静态资源和后端都不在服务器上,250下nginx配置:nginx.conf

    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        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;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
        client_max_body_size 20m;
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
    
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;
    
        server {
            listen       80 default_server;
            listen       [::]:80 default_server;
            server_name  _;
            root         /usr/share/nginx/html;
    
            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;
    
            location / {
            }
    
            error_page 404 /404.html;
                location = /40x.html {
            }
    
            error_page 500 502 503 504 /50x.html;
                location = /50x.html {
            }
        }
    
    # Settings for a TLS enabled server.
    #
    #    server {
    #        listen       443 ssl http2 default_server;
    #        listen       [::]:443 ssl http2 default_server;
    #        server_name  _;
    #        root         /usr/share/nginx/html;
    #
    #        ssl_certificate "/etc/pki/nginx/server.crt";
    #        ssl_certificate_key "/etc/pki/nginx/private/server.key";
    #        ssl_session_cache shared:SSL:1m;
    #        ssl_session_timeout  10m;
    #        ssl_ciphers HIGH:!aNULL:!MD5;
    #        ssl_prefer_server_ciphers on;
    #
    #        # Load configuration files for the default server block.
    #        include /etc/nginx/default.d/*.conf;
    #
    #        location / {
    #        }
    #
    #        error_page 404 /404.html;
    #            location = /40x.html {
    #        }
    #
    #        error_page 500 502 503 504 /50x.html;
    #            location = /50x.html {
    #        }
    #    }
    
    }
    

    250下conf.d里的dami.conf

    server {
            listen 80;
            server_name test-dami.psi.shuhe.biz;
            location /{
                    proxy_pass http://192.168.0.106:9999;
            }
            location /psi {
                    proxy_pass http://192.168.0.250:8000;
            }
    }
    

    静态资源的dami.conf

    server {
    	 listen       9999;
    	server_name  test-dami.psi.shuhe.biz;
    	root   ..first-test-vuedist;
    	location ~ .*.(gif|jpg|jpeg|png|bmp|swf|js|css)$ {
      		add_header Cache-Control no-store;
    	} 
    	error_page   500 502 503 504  /50x.html;
    	location = /50x.html {
    		root   html;
    		} 
        }
    

    250下conf.d里的kindergarten.conf

    server {
           server {
            listen 80;
            server_name kindergarten.com;
            location /static {    # 斜杠直接跳前端比较好,前端判断sessionid过期或者username过期/不存在等跳转到登陆界面
                    proxy_pass http://192.168.0.100:8000;
                    proxy_set_header Host $host;
                    proxy_set_header X-Real-IP $remote_addr;
            }
            location / {    # csrf要记得在登陆视图函数圈上,不要总是注释掉
                    proxy_pass http://192.168.0.102:8093;
            }
    }
    

    静态资源的salary_youeryuan.conf

    server {
    	listen 8000;
    	server_name salary_youeryuan.com;
    	root ....salary_youeryuan_statics;
    	index html/index.html;
    }
    
  • 相关阅读:
    2012年几大传统编程语言就业趋势分析
    解决vs2010 utimate中文版添加Silverlight for WP7模板方案【WP7学习札记之一】
    ASP.NET中的加密与解密
    先睹为快:Visual Studio 11测试版已于2.29在微软官方网站正式发布
    五种常见的ASP.NET安全缺陷
    WP7开发平台介绍及开发注意事项【WP7学习札记之二】
    简单工厂模式【设计模式学习01】
    单例的若干实现总结与拓展
    按照“红线准则”设计布局【WP7学习札记之三】
    几个解放双手的 Go 开发利器
  • 原文地址:https://www.cnblogs.com/bqwzx/p/10577918.html
Copyright © 2011-2022 走看看