简体   繁体   English

我可以使用 https:127.0.0.1 吗?

[英]Can I use https:127.0.0.1?

I tried using https for localhost, Can I use https for 127.0.0.1 instead of http:127.0.0.1:8080?我尝试将 https 用于本地主机,我可以将 https 用于 127.0.0.1 而不是 http:127.0.0.1:8080 吗? My question is if I can use https to connect to localhost using the given ip?我的问题是我是否可以使用 https 使用给定的 ip 连接到 localhost? Please give me some response.请给我一些回应。

Simple answer yes, yes you can :)简单的回答是的,是的,你可以:)

HTTPS can be used in exactly the same way as HTTP. HTTPS 的使用方式与 HTTP 完全相同。 Please note that you are going to have to set up your server to support HTTPS and on which port (Default 443) it should run on.请注意,您必须将服务器设置为支持 HTTPS 以及它应该在哪个端口(默认 443)上运行。

If you use a port other than 443 you're going to have to explicitly add that port to your url (example https://127.0.0.1:8081 (or whatever your port is). Otherwise just https://127.0.0.1 should work如果您使用 443 以外的端口,则必须将该端口明确添加到您的 url(例如https://127.0.0.1:8081 (或任何您的端口)。否则只需https://127.0.0.1应该管用

Some links of interest:一些感兴趣的链接:

Yes you can.是的你可以。 Although, it really depends on your localhost environment and how you configure it.虽然,这实际上取决于您的本地主机环境以及您如何配置它。 What is your OS?你的操作系统是什么? What server are you running?你在运行什么服务器? Do you have a self-signed certificate for your browser to validate your localhost site?您是否有用于浏览器的自签名证书来验证您的 localhost 站点?

In my case, I am running Apache 2.4 WAMP stack on Windows 10. I have something like the following in my httpd-ssl.conf:就我而言,我在 Windows 10 上运行 Apache 2.4 WAMP 堆栈。我的 httpd-ssl.conf 中有类似以下内容:

<VirtualHost *:443>

    DocumentRoot "c:/wamp/www/"
    ServerName 127.0.0.1
    SSLEngine on
    ErrorLog "c:/wamp/logs/ssl_error.log"
    TransferLog "c:/wamp/logs/ssl_access.log"

    SSLCertificateFile "c:/wamp/bin/apache/apache2.4.23/conf/ssl.crt/ssl.crt"
    SSLCertificateKeyFile "c:/wamp/bin/apache/apache2.4.23/conf/ssl.key/ssl.key"
    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory  "c:/wamp/www/">
        Options All
        AllowOverride All
        Require local
    </Directory>

    BrowserMatch "MSIE [2-5]" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0

    CustomLog "c:/wamp/logs/ssl_request.log" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

So it looks like this:所以它看起来像这样:

Click to view点击查看

My self-signed certificate is marked as insecure by my browser, so you will see the warning on the address bar.我的自签名证书被我的浏览器标记为不安全,因此您将在地址栏上看到警告。

Notice, all server works differently.请注意,所有服务器的工作方式都不同。 You should read some documentations about your server first and find the best way to implement it.您应该先阅读一些关于您的服务器的文档,然后找到实现它的最佳方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM