将nginx.conf文件放在根目录下
在配置nginx的时候,最主要的是server部分:
nginx配置中路由跳转问题解决:
try_files $uri /index.html;
如果不加这一句,在路由跳转的时候会有问题
其余配置可参考以下源码:
worker_processes auto;
daemon off;
error_log stderr;
events {
worker_connections 2048;
}
http {
access_log off;
default_type application/octet-stream;
include mime.types;
sendfile on;
keepalive_timeout 20;
client_header_timeout 20;
client_body_timeout 20;
reset_timedout_connection on;
send_timeout 20;
gzip on;
tcp_nopush on;
port_in_redirect off;
server_tokens off;
server {
listen 8080;
server_name localhost;
location / {
root /usr/share/nginx/html;
try_files $uri /index.html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}