GithubHelp home page GithubHelp logo

Comments (2)

michaelliao avatar michaelliao commented on May 19, 2024

https不支持ip

from itranswarp.

HarrisonQi avatar HarrisonQi commented on May 19, 2024

我目前只想用ip来打开界面。
不知道是不是我配置不对还是什么的 。每次刷新页面静态文件老是指向https,如下图
image

我的nginx配置,如下
upstream itw_upstream {
server 127.0.0.1:2019 fail_timeout=3s;
}

http

server {

listen 80;

server_name localhost;

#rewrite ^(.*)$ http://127.0.0.1:2019 permanent;

root   /usr/share/nginx/html;

access_log /var/log/nginx/host.access.log;
error_log  /var/log/nginx/host.error.log;

client_max_body_size 2m;

gzip            on;
gzip_min_length 1k;
gzip_buffers    4 8k;
gzip_http_version 1.1;
gzip_comp_level 1;
gzip_types      text/css application/x-javascript application/json;

sendfile on;

location = /favicocan.ico {
    expires 10d;
}

location = /robots.txt {
    expires 10d;
}

location ~ /static/ {
if ($request_method ~* "(GET|POST)") {
add_header "Access-Control-Allow-Origin" *;
}

    if ($request_method = OPTIONS ) {
        add_header "Access-Control-Allow-Origin"  "http://127.0.0.1:2019";
        add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
        add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
        expires 300d;
        return 200;
    }

    proxy_pass         http://127.0.0.1:2019;
    proxy_read_timeout 3s;
}
location ~ /files/ {
    if ($request_method ~* "(GET|POST)") {
        add_header "Access-Control-Allow-Origin"  *;
    }

    if ($request_method = OPTIONS ) {
        add_header "Access-Control-Allow-Origin"  "http://118.25.135.7:2019";
        add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
        add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
        expires 300d;
        return 200;
    }

    proxy_pass         http://127.0.0.1:2019;
    proxy_read_timeout 3s;
}

location / {
    if ($http_user_agent ~* "python|curl|java|wget|httpclient|okhttp") {
        return 503;
    }
    proxy_pass       http://itw_upstream;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

}

我也是出现这个问题, 用ip访问时, 静态文件全部变成了https请求, 导致全部报错.
作者答非所问. 请问您解决了吗?

from itranswarp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.