Quantcast
Channel: Nginx redirect request to index file with angular deployement - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Nginx redirect request to index file with angular deployement

$
0
0

I have deployed an angular app on a nginx server ( unbuntu 20 on digital ocean), now to be able to directly access the url like www.example.com/test or to reload the page. I have modified the configuration file to add try_files like under the image but it doesn't work

`http {

    ##    # 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/*;

}`

I tried several configuration like adding 404 at the end of try_files, removing (listen, server_name, root) ...but none of these methods work.

when i reload or try to directly go to subdirectory like mywebsite.com/test i have a not found page like that.not found page

Folder structureenter image description here


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles



Latest Images