nginxwindows 本地配置

nginx 常用命令

taskkill /im nginx.exe -f // 杀死nginx进程
tasklist | findstr nginx 

nginx windows本地配置如下


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server{
    listen 80;
    index index.php index.html index.htm default.php default.htm default.html;
    root html;
    gzip on; #开启资源压缩
    gzip_min_length 2k;#设置页面允许压缩的最小字节
    gzip_buffers 4 16k;#设置压缩的内存大小 按16k大小的 4倍申请内存
    gzip_http_version 1.1;#设置http 协议版本
    gzip_comp_level 1; #设置压缩等级1-9 值越小速度越快 压缩比越小
    gzip_types text/plain application/x-javascript text/css application/xml image/jpeg image/gif image/png; # 设置压缩类型,没设置的不压缩
    gzip_disable msie6;
    location / {
		try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
		index index.php index.html index.htm default.php default.htm default.html;
	#proxy_pass http://192.168.0.54:8888/;
	
	}

	location @router {
		rewrite ^.*$ /index.html last;
	}
    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    #SSL-END
    
    #ERROR-PAGE-START  错误页配置,可以注释、删除或修改
    #error_page 404 /404.html;
    #error_page 502 /502.html;
    #ERROR-PAGE-END
    

    
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
        error_log off;
    }
    
    location ~ .*\.(js|css)?$
    {
        expires      12h;
        error_log off;
        gzip_static  on;
        gzip_proxied expired no-cache no-store private auth;  
    }

     location ^~ /exam-api/ {
       proxy_pass http://192.168.0.54:8888/;
    }

}




    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #           try_files $uri $uri/ /index.html;
    #    }
    #}
    # location /api/ {
    #           proxy_pass http://www.xiadachuan.cn/;
    #        }

}

你可能感兴趣的:(nginx,前端)