Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx静态资源和反向代理配置 #4

Open
isNeilLin opened this issue Oct 9, 2017 · 0 comments
Open

Nginx静态资源和反向代理配置 #4

isNeilLin opened this issue Oct 9, 2017 · 0 comments
Labels
网络&运维 网络协议和运维相关

Comments

@isNeilLin
Copy link
Owner

静态资源服务器

1、 开启gzip压缩
gzip on;
2、 开启缓存

location ~*  \.(jpg|jpeg|png|gif|ico|css|js)${
   expires 30d;
}

反向代理

alias和root的区别

  • root和alias都可以定义在location模块中,都是用来指定请求资源的真实路径
  • root的真实路径是root指定的值加上location指定的值
  • alias指定的路径是location的别名,不管location的值怎么写,资源的真实路径都是 alias 指定的路径
  • alias 只能作用在location中,而root可以存在server、http和location中。
  • alias 后面必须要用 “/” 结束,否则会找不到文件,而 root 则对 ”/” 可有可无。

示例

server {
	listen       80;
	server_name  localhost;

	gzip_min_length 1k;
	gzip_buffers 4 16k;
	gzip_comp_level 5;
	gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php application/javascript;
	gzip  on;
	#charset koi8-r;
	#access_log  /var/log/nginx/host.access.log  main;

	root /home/ubuntu/wx-render/dist;
	index index.html;

	location ~*  \.(jpg|jpeg|png|gif|ico|css|js)${
	   expires 30d;
	}

	location /admin {
		root home/ubuntu/wx-server/bin;
		index www;
		proxy_pass http://127.0.0.1:3000;
	}
}

相关资料1
相关资料2

@isNeilLin isNeilLin added the 网络&运维 网络协议和运维相关 label Oct 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
网络&运维 网络协议和运维相关
Projects
None yet
Development

No branches or pull requests

1 participant