标签: https

强制某些URL上的HTTPS并强制所有其他URL使用HTTP

我有一个客户端项目,我需要为某个文件夹强制使用HTTPS,并强制所有其他文件夹使用HTTP.我可以成功地为我想要的文件夹强制执行HTTPS,但所有链接回到网站的其余部分最终都是通过HTTPS.我想有一条规则强制请求安全文件夹中的任何"不"被强制回HTTP.这是我到目前为止所拥有的:

RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]

RewriteCond %{HTTPS} !=on
RewriteRule ^(my) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1
Run Code Online (Sandbox Code Playgroud)

'my'是我需要强制HTTPS的文件夹的名称.

有任何想法吗?

更新:我也尝试过:

RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]

# Force HTTPS for /my
RewriteCond %{HTTPS} !=on
RewriteRule ^(my) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]

# Force HTTP for anything which isn't /my
RewriteCond %{HTTPS} =on
RewriteRule !^my http://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]

# Remove index.php from URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1
Run Code Online (Sandbox Code Playgroud)

但是,不是通过HTTPS强制/我被强制请求,他们现在只需要解析为http://www.example.com/index.php/my

:?

apache mod-rewrite https http

18
推荐指数
1
解决办法
8万
查看次数

如何在MVC3中使用https生成绝对URL?

我正在使用MVC3并尝试从https提供内容,问题是当我调用Url.Content时,仍然使用相对URL从http提供文件.我认为这个问题在MVC3中得到了解决,但我似乎无法找到任何解决方案.有没有人知道这个问题是否在MVC3中固有地解决了以及如何实现它或者我是否需要创建自己的辅助方法来生成基于协议的绝对Url?

asp.net asp.net-mvc https routes asp.net-mvc-3

18
推荐指数
3
解决办法
2万
查看次数

Android DownloadManager和SSL(https)

哦,太好了.总有一些东西...... Grrr ......

无论如何,所以我花了几天时间跋涉模糊,不完整和矛盾的Picasa信息,以便我的Android应用程序可以找到Picasa图片并使用下载管理器下载它.所以刚才我做了最后的润色并点击了"运行"按钮.一切顺利,直到DownloadManager尝试下载文件:

java.lang.IllegalArgumentException: Can only download HTTP URIs: https://example.com/image.jpg
Run Code Online (Sandbox Code Playgroud)

告诉我你在开玩笑.告诉我他们没有制作无法处理SSL的下载管理器......

更好的是,告诉我如何在Android下载管理器中启用SSL访问.

ssl https android download-manager

18
推荐指数
2
解决办法
2万
查看次数

如何在squid3中配置HTTPS支持

我有vps,我想配置我的squid支持HTTPS代理.我已配置http代理并且正常工作,但不支持https.

题

  • 如何在squid3中配置HTTPS代理?

这是我的squid.conf配置细节.

acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports …
Run Code Online (Sandbox Code Playgroud)

https proxy debian squid

18
推荐指数
1
解决办法
8万
查看次数

requests_mock NoMockAddress 异常

我目前正在尝试使用 requests_mock 库进行单元测试,以便修补请求。我编写了以下代码:

def test_general_search(requests_mock):
    params = {'query': 'testsetset', 'exact': 0, 'max_pages': '1', 'category': 'username'}
    requests_mock.get(f'{MOCK_ADDRESS}', json=MOCK_RESPONSE)
    client = Client(MOCK_ADDRESS, auth=MOCK_CREDS, headers=MOCK_HEADERS)
    res = general_search(client, params)
    assert ...
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

requests_mock.exceptions.NoMockAddress: No mock address: GET https://fake-url.com/search?query=username%3Atestsetset&page=1
Run Code Online (Sandbox Code Playgroud)

谁能帮我弄清楚如何解决它?我使用模拟作为 pytest 功能。

python https requests-mock

18
推荐指数
1
解决办法
1万
查看次数

HTTPS-> HTTP通过Fiddler

我正在寻找一种方法来使用Fiddler将HTTPS会话代理到HTTP会话中,因此当Fiddler在服务器前处理HTTPS会话时,资源管理器将使用HTTP会话:

客户端(资源管理器)< - http - > Fiddler < - https - >服务器

有人可以说如果可以通过Fiddler脚本来完成吗?

如果您对另一个工具(不是Fiddler)有另外的想法,我愿意接受建议:)

谢谢!Yohay

https fiddler

17
推荐指数
2
解决办法
8597
查看次数

服务器返回HTTP响应代码:401为URL:https

我正在使用Java访问HTTPS站点,该站点以XML格式返回显示.我在URL本身传递登录凭据.这是代码片段:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
requestURL = "https://Administrator:Password@localhost:8443/abcd";

try { 
    InputStream is = null;
    URL url = new URL(requestURL);
    InputStream xmlInputStream =new URL(requestURL).openConnection().getInputStream();
    byte[] testByteArr = new byte[xmlInputStream.available()];
    xmlInputStream.read(testByteArr);
    System.out.println(new String(testByteArr));
    Document doc = db.parse(xmlInputStream);
    System.out.println("DOC="+doc);
} catch (MalformedURLException e) {
} 
Run Code Online (Sandbox Code Playgroud)

我正在该程序中创建一个不验证签名/未签名证书的信任管理器.但是,在运行上述程序时,我收到错误服务器返回的HTTP响应代码:401 for URL:https:// Administrator:Password @ localhost:8443/abcd

我可以在浏览器上使用相同的URL,并正确显示xml.请告诉我如何在Java程序中完成这项工作.

java https tomcat http-status-code-401

17
推荐指数
1
解决办法
10万
查看次数

java.lang.ClassCastException:libcore.net.http.HttpURLConnectionImpl无法强制转换为javax.net.ssl.HttpsURLConnection

我正在编写一些代码,通过HTTPS将文件从设备上传到云端.

相关片段:

HttpsURLConnection conn = null; 
URL url = new URL(urlstring);
conn = (HttpsURLConnection) url.openConnection(); // exception here.
Run Code Online (Sandbox Code Playgroud)

但演员阵容不会编译:

06-20 15:58:05.311: E/FNF(30286): java.lang.ClassCastException: libcore.net.http.HttpURLConnectionImpl cannot be cast to javax.net.ssl.HttpsURLConnection
Run Code Online (Sandbox Code Playgroud)

我发现了类似的问题:使用java类HttpsURLConnection,但我没有从sun包导入任何东西.

我的进口:

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import android.net.Uri;
import javax.net.ssl.HttpsURLConnection;
import android.util.Log;
import edu.mit.media.funf.storage.RemoteFileArchive;
import edu.mit.media.funf.util.LogUtil;
Run Code Online (Sandbox Code Playgroud)

有一段时间我一直在讨论这个问题吗?

java https android http urlconnection

17
推荐指数
1
解决办法
2万
查看次数

如何在WAMP服务器(v2.5)中启用https(localhost)URL?

我正在使用wamp服务器并在localhost中运行php项目.我想使用基于"https"的网址来测试我的项目.

我尝试使用" https:// localhost/myproject / "并将其重定向到"此网页不可用"页面.

我已将"php_openssl"和"ssl"模块启用到apache配置中.但仍无法访问基于https的网址.

php apache ssl https wamp

17
推荐指数
2
解决办法
6万
查看次数

Angular 4:"(未知URL)的Http失败响应:0未知错误"

我正在尝试使用API​​ URL.我用以下代码调用API.

import {HttpClient, HttpClientModule, HttpParams} from "@angular/common/http";

@Injectable()
export class PropertyPrefService {

    constructor(private http: HttpClient,
                private configurationService:Configuration) {}

    public searchProjects(propFilter:string):any{
        let temp:any;
        const options = propFilter ?
        {
            params: new HttpParams().set('query', propFilter)
        } : {};

        return this.http.get<any>(this.configurationService.propertySystemApiUrl, options)
                    .subscribe((results:any) => {
                        console.log(results);
                    });
    }
Run Code Online (Sandbox Code Playgroud)

在Angular代码中,我没有得到任何响应,并且收到错误:

(未知网址)的Http失败响应:0未知错误".

但是,当我在Chrome上打开开发人员工具时发出请求时,我看到响应是从服务器收到的.

URL是"https:// ..."URL而不是"http:// ...".

https httpclient typescript angular angular4-httpclient

17
推荐指数
2
解决办法
3万
查看次数