美文网首页Nginx高端成长之路
前端Nginx配置 nginx.conf文件配置

前端Nginx配置 nginx.conf文件配置

作者: small_Sun | 来源:发表于2019-11-28 15:18 被阅读0次

    将nginx.conf文件放在根目录下

    在配置nginx的时候,最主要的是server部分:


    image.png

    nginx配置中路由跳转问题解决:

    try_files $uri /index.html;
    

    如果不加这一句,在路由跳转的时候会有问题

    其余配置可参考以下源码:

    worker_processes auto;
    daemon off;
    
    error_log stderr;
    events {
        worker_connections 2048;
    }
    
    http {
        access_log off;
        default_type application/octet-stream;
        include mime.types;
        sendfile on;
        keepalive_timeout 20;
        client_header_timeout 20;
        client_body_timeout 20;
        reset_timedout_connection on;
        send_timeout 20;
        gzip on;
        tcp_nopush on;
        port_in_redirect off;
        server_tokens off;
        server {
            listen  8080;
            server_name  localhost;
        
            location / {
                root /usr/share/nginx/html;
                try_files $uri /index.html;
                index index.html index.htm;
            }
    
            error_page 500 502 503 504 /50x.html;
            location = /50x.html {
                root html;
            }
        }
    }
    

    相关文章

      网友评论

        本文标题:前端Nginx配置 nginx.conf文件配置

        本文链接:https://www.haomeiwen.com/subject/mvsbwctx.html