nginx的能跑起来的最简单nginx.conf的配置


events {
  worker_connections  1024;  ## Default: 1024
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#前端设置了baseUrl的对应配置

server {
listen 80;
server_name localhost;

#charset koi8-r;
#access_log logs/host.access.log main;
root E:\project\dist; #单页面项目的打包后的dist目录
# http://localhost/kcart/detail/1
# http://localhost/kcart/js/about.8187b66d.js
location /cart {
    try_files $uri /cart/index.html;
}
#nginx反向代理,实现接口转发
location ^~ /api/ {
    proxy_pass http://localhost:3000; #注意路径后边不要加/
}
}
}

你可能感兴趣的:(nginx)