Xamapp 配置游戏服务器域名、SSL、禁止IP访问、IP跳转

1 篇文章 0 订阅

零、需求

a.符合合规性检查

b.开启域名访问80

c.禁止IP直接访问80

d.IP直接访问80跳转指定HTTP、HTTPS

e.HTTP跳转HTTPS(具体情况使用,老游戏不支持HTTPS)

项目文件:C:\BF\Xampp\apache\conf\extra

用到的文件:

httpd-ssl.conf

httpd-vhosts.conf

用到的证书请自备。

一、配置SSL

打开C:\BF\Xampp\apache\conf\extra\httpd-ssl.conf

httpd-ssl.conf,在最后添加一下代码:

<VirtualHost _default_:443>
    DocumentRoot "C:\BF\Xampp\htdocs" 
    ServerName bfl.域名.cn:443
    SSLEngine on
    SSLProtocol all -SSLv2 -SSLv3
    SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
    SSLHonorCipherOrder on
    SSLCertificateFile "king_ssl/域名.cn.crt"
    SSLCertificateKeyFile "king_ssl/域名.cn.key"
</VirtualHost>  

这里的根目录是在C:\BF\Xampp\apache

即证书文件应该放在:C:\BF\Xampp\apache\king_ssl

二、允许域名:80访问

C:\BF\Xampp\apache\conf\extra\httpd-vhosts.conf

httpd-vhosts.conf,在最后添加一下代码:

<VirtualHost *:80>  

    DocumentRoot "C:\bf\xampp\htdocs"  
    ServerName bfl.域名.cn 
        <Directory />  
            Options Indexes FollowSymLinks Includes ExecCGI  
            AllowOverride All  
            Require all granted  
        </Directory>  

</VirtualHost>  

三、配置禁止IP访问(建议步骤四)

在 xampp 的安装目录下,打开 /apache/conf/extra/httpd-vhosts.conf,在最后添加一下代码:

<VirtualHost *:80>  

    ServerName 106.x.x.x
        <Directory />  
            deny from ALL
        </Directory>  
	
</VirtualHost>  

其中,ServerName 106.*.*.* 是你的服务器 IP 地址,之后重启 Apache,再次通过 IP 直接访问你的网站,就提示错误。不能访问。使用可以配置ServerAdmin admin@域名.com 使用。 

四、推荐的方法是IP访问直接跳转

C:\BF\Xampp\apache\conf\extra\httpd-vhosts.conf

httpd-vhosts.conf

<VirtualHost *:80>
    ServerName 106.x.x.x
    ServerAlias 
 
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTP_HOST} !^blog.域名.cn$
        RewriteRule ^/(.*)$ http://blog.域名.cn/$1 [R=301,L]
    </IfModule>

</VirtualHost>

五、步骤二+步骤四一起使用

C:\BF\Xampp\apache\conf\extra\httpd-vhosts.conf

httpd-vhosts.conf

<VirtualHost *:80>  

    DocumentRoot "C:\bf\xampp\htdocs"  
    ServerName bfl.域名.cn 
        <Directory />  
            Options Indexes FollowSymLinks Includes ExecCGI  
            AllowOverride All  
            Require all granted  
        </Directory>  

</VirtualHost>  



<VirtualHost *:80>
    ServerName 106.x.x.x 
    ServerAlias 
 
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTP_HOST} !^blog.域名.cn$
        RewriteRule ^/(.*)$ http://blog.域名.cn/$1 [R=301,L]
    </IfModule>

</VirtualHost>

六、跳转HTTPS

<VirtualHost *:80>
    ServerName 域名.cn
    RewriteEngine on
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*) https://%{SERVER_NAME}$1 [L,R]
</VirtualHost>

七、提示

通过proxy方式跳转,在Windows下亲测不行,报错。

ServerAdmin admin@域名.com,会在报错时显示。  

<VirtualHost *:80>  
    ServerAdmin admin@域名.com  

        <Directory />  
            
        </Directory>  

</VirtualHost>  

解析  DocumentRoot  为服务器访问的目录; ServerName 为刚才设置的虚拟域名。

八、参考资料

xampp 域名配置_xampp配置域名-CSDN博客

httpd两种简单跳转方式_httpd 访问ip直接跳转到页面-CSDN博客

网站⭐Windows下,将xampp升级为https_xampp ssl-CSDN博客

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值