V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
cuixiao603
V2EX  ›  程序员

nginx 一个很奇怪的问题来请教一下

  •  2
     
  •   cuixiao603 · 2019-01-30 17:24:28 +08:00 · 1921 次点击
    这是一个创建于 1884 天前的主题,其中的信息可能已经有所发展或是发生改变。

    配置完 https 以后其他一切正常,但是图片资源的路由不太正确了

    加载路径为 https://172.16.110.16/css/assets/a6d4c7c382b025fbee59ad784f257560.png

    正确的加载路径为: https://172.16.110.16/assets/a6d4c7c382b025fbee59ad784f257560.png

    不知道为什么凭空出现了 /css/

    第 1 条附言  ·  2019-01-30 17:56:28 +08:00
    找到原因了 因为 index.css 里面使用的是相对目录引入图片,index.css 在 css 目录下导致目录路径前面多了个 css,但是奇怪的是不配置 https 时候没发现这个问题
    第 2 条附言  ·  2019-01-30 17:56:47 +08:00
    感谢各位大佬啊
    cydian
        1
    cydian  
       2019-01-30 17:25:47 +08:00 via Android   ❤️ 1
    路径最开头加了/没有?
    绝对 相对路径?
    ysc3839
        2
    ysc3839  
       2019-01-30 17:26:07 +08:00 via Android   ❤️ 1
    发 css 代码看看?
    cuixiao603
        3
    cuixiao603  
    OP
       2019-01-30 17:28:08 +08:00
    @ysc3839 代码是前端编译好的应该没什么价值吧
    cuixiao603
        4
    cuixiao603  
    OP
       2019-01-30 17:29:54 +08:00
    @cydian 加了的 ,https://172.16.110.16/css/index.css 都是加载正常的
    css 和 assets 是两个平级的目录
    yazi
        5
    yazi  
       2019-01-30 17:31:42 +08:00
    这和 Nginx 没什么关系吧
    cuixiao603
        6
    cuixiao603  
    OP
       2019-01-30 17:33:13 +08:00
    @yazi nginx 不配置 https 是没问题的
    LeeSeoung
        7
    LeeSeoung  
       2019-01-30 17:34:26 +08:00   ❤️ 1
    事出有因必有妖。。前台代码。。nginx 配置好好排查下。换个目录看下问题复现不。
    kernnel
        8
    kernnel  
       2019-01-30 17:42:37 +08:00   ❤️ 1
    这个应该和 nginx 没关系,大概率是前端配置问题,比如 webpack 的 css output 目录配置
    cuixiao603
        9
    cuixiao603  
    OP
       2019-01-30 17:56:09 +08:00
    找到原因了 因为 index.css 里面使用的是相对目录引入图片,index.css 在 css 目录下导致目录路径前面多了个 css,但是奇怪的是不配置 https 时候没发现这个问题
    cydian
        10
    cydian  
       2019-01-30 18:02:51 +08:00 via Android
    @cuixiao603 一开始就回复你这个问题了
    cuixiao603
        11
    cuixiao603  
    OP
       2019-01-30 18:12:33 +08:00 via Android
    @cydian 哈哈 理解错了 我的锅
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3146 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 12:32 · PVG 20:32 · LAX 05:32 · JFK 08:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.