nginx转发url和映射本地资源

nginx的基本转发和映射配置

一. nginx转发url

server {listen       80;server_name  localhost;location / {root   html;index  index.html index.htm;}# 配置将 `http://127.0.0.1:80/test1` 转发至 `http://127.0.0.1:8080`location /test1 {proxy_pass   http://127.0.0.1:8080/;	# 需要转发的url地址index  index.html index.htm;}}

二.nginx映射本地静态资源

server {listen       80;server_name  localhost;location / {root   html;index  index.html index.htm;}# 配置映射本地资源:本地路径 `E:/temp/`,访问地址 `http://127.0.0.1:80/image/图片名称(包含后缀)`location /image/ {root   E:/temp/;	#静态资源的本地目录rewrite ^/image/(.*)$ \$1 break;}}


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部