我在我的机器上运行本地 Node js 服务器,并为其提供一个ngrok.io域。
如果我在网络浏览器中本地运行它,localhost:3000则http://1234.ngrok.io一切正常。如果我调用它,httpS://1234.ngrok.io我会收到错误
Mixed Content: The page at 'https://1234.ngrok.io/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://localhost:3000/calculation'. This request has been blocked; the content must be served over HTTPS.
Run Code Online (Sandbox Code Playgroud)
由于路由不是http造成的。我怎样才能解决这个问题?
这是我的node.js 上的app.js
const express = require('express');
const app = express();
const https = require('https');
const http = require('http');
const fs = require('fs');
app.use('/', express.static(__dirname + '/../Client'));
var options = {
key: fs.readFileSync('./https_certificate/client-key.pem'),
cert: fs.readFileSync('./https_certificate/client-cert.pem')
};
app.listen(server_connection.port, () …Run Code Online (Sandbox Code Playgroud) 我正在开发一个肥皂服务器,它将为一些具有旧版肥皂协议的旧嵌入式计算机提供服务。
我用go编写它,到目前为止只使用 plain http,但在生产中它必须使用ssl加密。所以我刚刚创建了一个密钥和一个证书(来自此站点)并使用了该http.ListenAndServeTLS功能。
但现在计算机无法连接,服务器只是打印握手错误:
server.go:2848: http: TLS handshake error from [::1]:38790: tls: no cipher suite supported by both client and server
在文档中,对于计算机,不是支持的 ssl 版本或密码。所以我想知道,如何找出客户端的 ssl 版本,以及客户端支持的可用密码套件。
然后我如何配置 golang http 服务器以支持所选的密码。
我正在尝试创建一个通过 http 协议与服务器通信的 Android 应用程序。我正在使用 Retrofit 向服务器发送 GET 请求,但总是收到以下错误:
java.net.UnknownServiceException: CLEARTEXT communication to http://demo5373349.mockable.io/ not permitted by network security policy
Run Code Online (Sandbox Code Playgroud)
虽然尝试通过 https 访问服务器时不存在此类问题,但我也会编写服务器端,并且我应该使用 http。
这是代码:
private TextView textView;
private EditText editText;
private Button getButton;
private Retrofit retrofit;
private ServerConnection connection;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
retrofit = new Retrofit.Builder()
.baseUrl("http://demo5373349.mockable.io/")
.addConverterFactory(GsonConverterFactory.create())
.build();
connection = retrofit.create(ServerConnection.class);
textView = findViewById(R.id.textView);
editText = findViewById(R.id.editText);
getButton = findViewById(R.id.buttonGET);
getButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getHandler();
}
});
} …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试从深度学习交易所收集数据。问题是我需要高分辨率(秒间隔)的数据,因此我为每种货币创建大量 GET 请求。但我确实很快就达到了 API 的极限。
我想知道是否有可能通过公共代理服务器路由 GET 请求,以声明拥有不同的 IP 地址,以便使用 Raspberry PI 发出尽可能多的请求。
我是 Nginx 配置的新手,我有一个进程,它是一个快速应用程序,使用 pm2 在端口 3000 上运行,我也允许使用 ufw 端口 3000,并在 Nginx 上创建了一个服务器实例来代理它,
server {
# SSL configuration
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name .mysite.co;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/django/mysite;
}
proxy_cache mysite;
location / {
include proxy_params;
proxy_pass http://unix:/home/django/mysite/mysite.sock;
}
gzip_comp_level 3;
gzip_types text/plain text/css image/*;
ssl_certificate /etc/letsencrypt/live/mysite.co/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mysite.co/privkey.pem; # managed by Certbot
}
server {
if ($host = www.mysite.co) {
return 301 …Run Code Online (Sandbox Code Playgroud) 我决定在 Django 1.11.4 中启用 https。
谢谢“让我们加密”。
所以我将所有 http 请求重定向 (301) 到 https。此外,所有非 www(http 或 https)都会重定向 (301) 到https://www
它工作正常,除了我的网址https://www.example.com/sitemap.xml,它目前不起作用,并且自 https 传递以来。
它返回 500 错误代码,我真的不知道为什么。
urls.py
from django.conf.urls import url
from django.contrib.sitemaps.views import sitemap
from example.sitemaps import *
from django.conf import settings
#Pour charger le favicon
media = settings.MEDIA
# Dictionary containing sitemap classes
sitemaps = {
'products': ArticleSitemap(),
}
urlpatterns = [
url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'),
]
Run Code Online (Sandbox Code Playgroud)
站点地图.py
#Generating Sitemap for Dynamic Urls
from django.contrib.sitemaps import Sitemap …Run Code Online (Sandbox Code Playgroud) 我想在 node.js 中实现代理服务器,这有点类似于 Charles 代理 - 它应该拦截来自我的移动应用程序的 HTTPS 请求,破译它们,根据正文内容将其中一些请求路由到原始后端,并使用一些静态文件模拟其他请求。
我尝试使用节点https api来设置https服务器,在api文档中:有两个参数让我感到困惑。 加利福尼亚州:
(可选)覆盖受信任的 CA 证书。默认是信任由 Mozilla 管理的知名 CA。当使用此选项显式指定 CA 时,Mozilla 的 CA 将被完全替换。该值可以是字符串或缓冲区,或者字符串和/或缓冲区的数组。任何字符串或缓冲区都可以包含多个连接在一起的 PEM CA。对等方的证书必须可链接到服务器信任的 CA,以便对连接进行身份验证。当使用不可链接到知名 CA 的证书时,必须将证书的 CA 明确指定为受信任的 CA,否则连接将无法进行身份验证。如果对等方使用的证书与默认 CA 之一不匹配或链接到,请使用 ca 选项提供对等方证书可以匹配或链接到的 CA 证书。对于自签名证书,该证书是其自己的 CA,并且必须提供。对于 PEM 编码的证书,支持的类型为“TRUSTED CERTIFICATE”、“X509 CERTIFICATE”和“CERTIFICATE”。
证书:
PEM 格式的证书链。每个私钥应提供一个证书链。每个证书链应包含所提供私钥的 PEM 格式的证书,后跟 PEM 格式的中间证书(如果有),按顺序排列,并且不包括根 CA(根 CA 必须是对等方预先知道的,参见约)。当提供多个证书链时,它们的顺序不必与其私钥在 key 中的顺序相同。如果未提供中间证书,对等方将无法验证证书,握手将失败。
他们之间有什么区别?正如我所想,https系统中只有一个客户端pem和一个密钥pem。为什么需要更多像 ca 和 cert 这样的东西?我通过 certbot 生成 pem,生成了四个文件:cert.pem chain.pem fullchain.pem
privkey.pem. 两者有何不同cert.pem chain.pem fullchain.pem?
我在 golang 中构建了一个小型应用程序,使用 alpine:golang 基本映像,该映像除其他外还消耗来自 HTTP.get 的响应。
我请求的 api 端点通过 HTTPS 运行(https://jsonplaceholder.typicode.com/users)
代码在本地运行良好,并且 docker 映像构建良好,但运行时出现以下错误:
The HTTP request failed with error Get "https://jsonplaceholder.typicode.com/users": x509: certificate signed by unknown authority
Run Code Online (Sandbox Code Playgroud)
我不确定这是否是一个特定的 Docker 问题(我无法从其他 docker 容器卷取 HTTPS)、我的网络限制(我没有使用 VPN,但我们确实使用 zScaler),或者我是否需要包含/configure 一些东西作为我的 Dockerfile 的一部分。我的 dockerfile 看起来像:
FROM alpine:golang
#Create and set the working directory
RUN mkdir /app
WORKDIR /app
# Copy all the go scripts into the image working directory
COPY /pipelines/core/rtbf-pipeline-1 ./
# Make the binaries executable
RUN chmod +x /app/rtbf-pipeline-1 …Run Code Online (Sandbox Code Playgroud) 在 Firefox 中浏览时,我可以看到http://www.chicagotribune.com/ct-florida-school-shooter-nikolas-cruz-20180217-story.html 。但是,newspaper3k给了我这个错误:
Article download() failed with HTTPSConnectionPool(host='www.chicagotribune.com', port=443): Read timed out. (read timeout=7) on URL http://www.chicagotribune.com/ct-florida-school-shooter-nikolas-cruz-20180217-story.html
Run Code Online (Sandbox Code Playgroud)
我的代码是:
from newspaper import Article
from newspaper import Config
user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0'
config = Config()
config.browser_user_agent = user_agent
url = "https://www.chicagotribune.com/nation-world/ct-florida-school-shooter-nikolas-cruz-20180217-story.html"
page = Article(url, config=config)
page.download()
page.parse()
print(page.text)
Run Code Online (Sandbox Code Playgroud)
我认为像“renewIPAddress()”之类的东西可能会有所帮助,但我不确定如何准确地将其适合此代码。/sf/answers/3534773791/