SpringCloud项目用nginx代理访问静态页面
Nginx (engine x) 是一个高性能的和服务器,也是一个IMAP/POP3/SMTP。Nginx也可作为:Nginx 既可以在内部直接支持 Rails 和 PHP 程序对外进行服务,也可以支持作为 HTTP对外进行服务。这些大家应该不陌生。不了解的请自行百度,今天讲讲SpringCloud项目用nginx代理访问静态页面。本地的Nginx 目录如下:
SpringCloud项目的ui文件:
然后就修改nginx文件夹的conf下的配置nginx.conf文件配置如下内容:
server { listen 7071; #监听端口 server_name localhost; autoindex on; #是否允许访问目录 #access_log logs/host.access.log main; #charset utf-8; #静态页面目录 root C:UsersAdministratoreclipseadmin-ui; #默认首页 index login.html; location / { autoindex on; location ~* .(css|js|jpg|gif|png|swf|htm|html|json|xml|svg|woff|ttf|eot|mao|ico)$ { expires 1h; autoindex on; if ( -f $request_filename){ break; } } #网关配置地址 if ( !-e $request_filename){ proxy_pass http://localhost:3001; #SpringCloud网关中配置的端口号 #proxy_pass http://localhost:10000; } } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
然后保存启动nginx 访问127.0.0.1/7072(监听端口号)/admin(静态文件文件夹名称)即可