ini AngularJS Nginx和html5Mode

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ini AngularJS Nginx和html5Mode相关的知识,希望对你有一定的参考价值。

server {
    server_name yoursite.com;
    root /usr/share/html;
    index index.html;
    
    location / {
        try_files $uri $uri/ /index.html;
    }
}

ini 单页面应用程序的配置(框架:Angularjs,Web服务器:Nginx)

server {
  listen 80 default deferred;

  server_name myapp.com;

  root /var/www/project-folder/;

  # Nginx and Angularjs with html mode 5 - https://gist.github.com/cjus/b46a243ba610661a7efb
  index index.html;

  location / {
    try_files $uri $uri/ /index.html;
  }

  # Location of asset folder
  location ~ ^/(assets)/  {
    gzip_static on;
    gzip_types text/plain text/xml text/css 
      text/comma-separated-values
      text/javascript application/x-javascript
      application/atom+xml;

    expires max;
  }

  # Defines the URI that will be shown for the specified errors. 
  # error_page directives are inherited from the previous level 
  # only if there are no error_page directives defined on the current level. 
  # A uri value can contain variables.
  error_page  404 /404.html;

  # Sets the maximum allowed size of the client request body, 
  # specified in the “Content-Length” request header field. 
  # If the size in a request exceeds the configured value, 
  # the 413 (Request Entity Too Large) error is returned to the client. 
  # Please be aware that browsers cannot correctly display this error. 
  # Setting size to 0 disables checking of client request body size.
  client_max_body_size 4G;

  # The first parameter sets a timeout during which a keep-alive 
  # client connection will stay open on the server side. 
  # The zero value disables keep-alive client connections. 
  # The optional second parameter sets a value in the “Keep-Alive: timeout=time” response header field. 
  # Two parameters may differ.
  keepalive_timeout 10;
}

以上是关于ini AngularJS Nginx和html5Mode的主要内容,如果未能解决你的问题,请参考以下文章

使用 HTML5Mode 配置多个 AngularJS2 项目的 Nginx 配置

ini 单页面应用程序的配置(框架:Angularjs,Web服务器:Nginx)

ini HTML5模式下Vue-Router的NGiNX配置

ini HTML5模式下Vue-Router的NGiNX配置

ini HTML5模式下Vue-Router的NGiNX配置

ini HTML5模式下Vue-Router的NGiNX配置