首页 > 系统相关 >路由和Nginx

路由和Nginx

时间:2022-10-16 11:45:50浏览次数:37  
标签:index ssl 404 Nginx html location 路由

history路由前端router实现

history路由刷新页面流程

一个新的请求发起后 --> 后端路由 -> 后端路由规则返回内容 --> 浏览器加载页面内容 --> 前端路由处理渲染 -> 按前端路由规则修改页面内容 --> 结束

Nginx配置参考

    server {
        listen       80;
        server_name  <your-server-name>;
    # http 转成 https,配置了ssl证书时启用
    return 301 https://$host$request_uri;

    # 解决history路由刷新问题
    location / {
        # index.html文件在服务器中的存储目录
        root /data/www;  # /data/www需要修改为你服务器中的目录
        index index.html index.htm;
        
        #资源访问失败后定向到index.html
        try_files $uri $uri/ /index.html;
    }

    error_page 404 /404.html;
    location = /404.html {
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}

# SSL证书配置
server {
    listen       443 ssl;
    server_name  &lt;your-server-name&gt;;

    ssl_certificate &lt;your_ssl_certificate_filepath&gt;;
    ssl_certificate_key &lt;your_ssl_certificate_key_filepath&gt;;
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;

    # 解决http转https后路由报错问题
    location / {
        root /data/www;
        index index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

    error_page 404 /404.html;
    location = /404.html {
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}

  

标签:index,ssl,404,Nginx,html,location,路由
From: https://www.cnblogs.com/fengnovo/p/16795856.html

相关文章

  • docker nginx 容器(temp)
    一、安装docker二、下载nginx容器命令:dockerpullnginx 三、启动容器dockerrun-p8000:80-dnginxs 四、编写index.html页面viindex.html写入hellow......
  • nginx
    nginx1.nginx简介  2.lnmp工作原理 3.nginx参数与模块介绍 --prefix=/usr/local/nginx #/指定安装路径--with-http_stub_status_module   #/安装状态......
  • nginx反向代理多个docker容器(基于端口代理)
    一台已安装docker的服务器(安装过程此处省略)安装nginx,这里我直接在本机安装nginx(发行版为opensuse),参考链接:SuseLinux12Nginx安装-简书(jianshu.com)添......
  • Nginx rewrite 的last、break、redirect、permanent区别
    Nginxrewrite的last、break、redirect、permanent有四种模式: last和break都会跳转的rewrite的地址,区别是:last跳转后,会重新发起请求再匹配一次location,而break则只......
  • 查找nginx路径
    1.查找nginxwhichnginx输出/usr/local/bin/nginx2.查找nginx配置文件/usr/local/bin/nginx-t#检测配置是否正确,同时可以输出配置文件路径输出:nginx......
  • Vue路由跳转后,页面和滚动条不在最顶部。
    在路由跳转后,页面以及滚动条保持在当前位置,没用回到最顶部怎么办?解决方法如下:在main.js中加入以下代码router.afterEach((to,from,next)=>{window.scrollTo(0,0)})......
  • Vue3动态路由传参;获取动态路由传入参数;
           路由文件,配置动态路由( /:  -后面的tabsItem为参数名称,参数名后的?号 -使参数可以为空而不报错  )1{2//关于我们3......
  • egg.js 24.3-24.5router路由相关
    编写路由基础用法//router.jsrouter.get('/admin/:id',controller.admin.index);//controllerasyncindex(){const{ctx}=this;//获取路由get传值参数(路由......
  • nginx负载均衡示例讲解
    有任何问题都可以留言咨询。 常用的几种负载均衡方法1、round-robin轮询方法。默认的负载均衡方法。顾名思义就是循环的一个个来。把应用程序的请求,循环的分发到不......
  • nginx访问控制,用户认证,配置https,zabbix监控nginx状态页面
    nginx访问控制,用户认证,配置https,zabbix监控nginx状态页面nginx访问控制,用户认证,配置https,zabbix监控nginx状态页面nginx访问控制nginx用户认证nginx配置httpszabbix监......