Nginx配置中的重载时Angular 6路由抛出错误

时间:2018-09-04 15:10:27

标签: nginx routes angular6

这似乎是一个正常的问题,我已经做了很多检查。在应用可能的检查后,我仍然遇到相同的错误。

 root /var/www/html;
        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;

        server_name abc.com www.abc.com;

        ssl on;
        ssl_certificate /etc/nginx/ssl/server.crt;
        ssl_certificate_key /etc/nginx/ssl/server.key;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;


        location / {
                root /opt/workspace/myapp/;
                try_files $uri $uri/ /index.html;
                #try_files $uri$args $uri$args/ /index.html;
                proxy_set_header   X-Forwarded-For $remote_addr;
                proxy_set_header   Host $http_host;
                proxy_pass         "http://XXX.XXX.XXX.XXX:4200";

        }
      location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
        #              fastcgi_pass 127.0.0.1:9000;
                       fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
                        fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
               }
               location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /phpMyAdmin {
               rewrite ^/* /phpmyadmin last;
        }

我使用try_files遵循了https://angular.io/guide/deployment for nginx,但无济于事。可能我在配置中犯了一些错误。

*注意:我正在使用 app_dist_folder / http-server . -p 4200

0 个答案:

没有答案