Apache-2.2

使用 IP 地址而不是伺服器名稱訪問伺服器

  • March 25, 2015

我正在嘗試通過以下地址訪問我的伺服器:

https://www.media-rewards.com/

但它不起作用:(。

但是,如果我使用它的 IP 地址,它可以工作:

https://52.0.245.209/

我不知道這兩個問題是否相關,但是:我可以訪問預設的 apache 頁面(/var/www/html/index.html)

http://52.0.245.209/

我想將它重定向到 https 地址,我在 apache 配置中嘗試過:

<VirtualHost *:80>
  ServerName www.media-rewards.com
  Redirect permanent /var/www/html https://www.media-rewards.com/
</VirtualHost>

<VirtualHost *:443>
   ServerName www.media-rewards.com
   Redirect permanent /var/www/html https://www.media-rewards.com/
</Virtualhost>

我懷疑這是因為 DNS 中的 A 記錄www.media-rewards.com不指向52.0.245.209,而是指向54.76.29.199

# dig www.media-rewards.com

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5_8.6 <<>> www.media-rewards.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18713
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.media-rewards.com.         IN      A

;; ANSWER SECTION:
www.media-rewards.com.  10800   IN      A       54.76.29.199

;; Query time: 335 msec
;; SERVER: xxx.xxx.xxx.xxx#53(xxx.xxx.xxx.xxx)
;; WHEN: Wed Mar 25 07:23:20 2015
;; MSG SIZE  rcvd: 55

引用自:https://serverfault.com/questions/678122