nginx配置静态页面
Posted python真好用
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx配置静态页面相关的知识,希望对你有一定的参考价值。
nginx静态页面的配置如下:(重要的都写在注释里了)
user root;
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;
sendfile on;
keepalive_timeout 65;
#gzip on;
server
listen 80;
server_name localhost;
#这个是配置主页的,访问localhost:80会直接跳转到index.html
location /
root /tomcat1/webapps/static/pages;
index index.html index.htm;
error_page 500 502 503 504 /50x.html;
location = /50x.html
root html;
#这个访问ip:80/pages会直接跳转到ip:80/pages/xh.html
location /pages
root /tomcat1/webapps/static/pages;
try_files $uri $uri/ /xh.html last;
#这个是用来配置静态资源的
location ~ .*\\.(txt|js|css|eot|gif|jpg|jpeg|png|woff|svg|mp4)?$
root /tomcat1/webapps/static;
#这个访问ip:80/test会直接跳转到ip:80/pages/test.html
location /test
root /tomcat1/webapps/static/pages;
try_files $uri $uri/ /test.html last;
以上是关于nginx配置静态页面的主要内容,如果未能解决你的问题,请参考以下文章