nginx.conf 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. user nginx;
  2. worker_processes 1;
  3. error_log /var/log/nginx/error.log warn;
  4. pid /var/run/nginx.pid;
  5. events {
  6. worker_connections 1024;
  7. }
  8. http {
  9. include /etc/nginx/mime.types;
  10. default_type application/octet-stream;
  11. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  12. '$status $body_bytes_sent "$http_referer" '
  13. '"$http_user_agent" "$http_x_forwarded_for"';
  14. access_log /var/log/nginx/access.log main;
  15. sendfile on;
  16. keepalive_timeout 65;
  17. server {
  18. listen 80;
  19. server_name localhost;
  20. # 处理跨域
  21. add_header Access-Control-Allow-Origin *;
  22. add_header Access-Control-Allow-Headers X-Requested-With;
  23. add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
  24. # Gzip压缩
  25. gzip on;
  26. gzip_min_length 5k;
  27. gzip_comp_level 3;
  28. gzip_types gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
  29. gzip_vary on;
  30. location / {
  31. root /app/dist;
  32. index index.html index.htm;
  33. try_files $uri $uri/ /index.html;
  34. }
  35. }
  36. }