我已经在nginx服务器上部署了一个angular应用程序(digital ocean上的unbuntu 20),现在可以直接访问www.example.com/test这样的url或重新加载页面。我已经修改了配置文件,在图像下添加try_files,但它不起作用
联系我们
##
# Basic Settings
##
server {
location / {
listen 80;
listen 443 ssl;
server_name pisqre.com;
root /var/www/html;
index index.html index.html;
try_files $uri $uri/ /index.html;
}
}
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;
server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}`
我尝试了几种配置,比如在try_files的末尾添加404,删除(listen,server_name,root)......但这些方法都不起作用。
当我重新加载或尝试直接去子目录像mywebsite.com/test我有一个没有找到这样的页面。
文件夹结构
1条答案
按热度按时间egdjgwm81#
更新:经过一些搜索,问题是ssl,所以我已经修改了nginx的conf文件。现在一切都好了