zoukankan      html  css  js  c++  java
  • nginx : server_name localhost 和 chrome : Provisional headers are shown

    问题相关

    nginx : server_name localhost
    chrome : Provisional headers are shown

    问题现象:

    使用nginx做代理,代理图片请求。

    1. #nginx.conf
    2. server {
    3. listen 80;
    4. server_name localhost;
    5. location ^~ /img/ {
    6. proxy_pass http://localhost:8000/;
    7. }
    8. server {
    9. listen 8000;
    10. server_name localhost;
    11. location /{
    12. root D:\img;
    13. }
    14. }

    用户chrome浏览器打开 localhost
    第一次打开页面加载图片正常,
    F5刷新后,
    图片就加载不出来了,
    再F5刷新,图片又可以加载出来,
    再F5刷新,图片又加载不出来了。
    总结,奇数次可以加载出来,偶数次加载不出来。

    解决思路

    F12 查看请求信息

    查看nginx的错误日志

    1. #error.log
    2. upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /img/1.jpg HTTP/1.1", upstream: "http://[::1]:8000/1.jpg", host: "localhost", referrer: "http://localhost/"

    然后一点点思路也没有。

    多次操作后,意识到可能是server_name localhost用的不对。改为用127.0.0.1

    然后就可以了,解决了!!:joy::joy::joy:

    解决方案

    nginx.conf 文件里的localhost全改为用127.0.0.1.
    (本地IP:192.168.1.x 也可以)

    1. #nginx.conf
    2. server {
    3. listen 80;
    4. server_name 127.0.0.1;
    5. location ^~ /img/ {
    6. proxy_pass http://127.0.0.1:8000/;
    7. }
    8. server {
    9. listen 8000;
    10. server_name 127.0.0.1;
    11. location /{
    12. root D:\img;
    13. }
    14. }

    总结

    现在也没想明白是怎么回事,请大大们指教。





  • 相关阅读:
    NHibernate错误集锦
    potree的第三方库
    potree的API说明文档
    potreeConverter之数据处理
    potreeConverter之环境配置
    SpringBoot读取配置文件信息
    SpringBoot启动tomcat失败
    AbstractRoutingDataSource动态切换数据源
    多数据源配置(Spring+mybatis)
    单一数据源配置(Spring+Mybatis)
  • 原文地址:https://www.cnblogs.com/ElEGenT/p/5549267.html
Copyright © 2011-2022 走看看