douhuang2218 2019-05-15 03:32
浏览 145

如何从互联网访问虚拟主机?

I want to access my website via virtual host from the internet. For now, I am using the public IP address of my server to access my website. Here is what I am using (please see below).

http://122.4.195.12:7777/site/index.php

  1. Is there a way to access my virtual host from the internet? When I am accessing my virtual host from my internet (https://mysite/site/index.php) I am getting

DNS_PROBE_FINISHED_NXDOMAIN error
mysite’s server IP address could not be found.

  1. Is there a way to add a SSL when accessing my website via public IP address? When I change http into https I am getting

ERR_SSL_PROTOCOL_ERROR
122.4.195.12 sent an invalid response.
http://122.4.195.12:7777/site/index.php -> https://122.4.195.12:7777/site/index.php

Here is my Virtual Host Config:

<VirtualHost *:7777>
DocumentRoot "C:\xampp\htdocs"
  ServerName mysite
  <Directory "C:\xampp\htdocs">
    Require all granted
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
<VirtualHost *:443>
     DocumentRoot "C:/xampp/htdocs"
     ServerName mysite
     SSLEngine on
     SSLCertificateFile "crt/scratchitsite/server.crt"
     SSLCertificateKeyFile "crt/mysite/server.key"
     <Directory "C:\xampp\htdocs">
        Require all granted
        AllowOverride All
        Order allow,deny
        Allow from all
      </Directory>
 </VirtualHost>

Here is the host file of my server:

127.0.0.1       mysite
  • 写回答

1条回答 默认 最新

  • dpea85385 2019-05-15 04:03
    关注

    For question 1

    The easier way will still be registering a domain name, point it to your IP address, and setup your VirtualHost ServerName for it

    The VirtualHost actually detecting the Host HTTP Header from server site, so the key thing here is:

    How to make the client browser send the Host header the same with you defined on server

    For example, by using CURL you can force it to use the user definied Host header like this: curl -H 'Host: mysite' 122.4.195.12:7777/site/index.php

    If you're using Chrome, you can try to use a browser extension, like this

    For question 2

    You've enabled HTTPS on port 443 instead of 7777 in your Apache configuration

    Which means you should access your HTTPS service like this https://122.4.195.12:443/site/index.php instead of this https://122.4.195.12:7777/site/index.php

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?