简体   繁体   中英

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? My question is if I can use https to connect to localhost using the given ip? Please give me some response.

Simple answer yes, yes you can :)

HTTPS can be used in exactly the same way as 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.

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

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?

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:

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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