Pagoda panel deploys Apache server to build a local site and publishes it to the public network for access [Intranet penetration]

Before I start, I would like to recommend a website to everyone. I found a huge artificial intelligence learning website a few days ago,< a i=3>Easy to understand, humorous, I can’t help but share it with everyone. Click to jump to the website.

Preface

As a simple and easy-to-use server operation and maintenance management panel, Pagoda Panel supports Linux/Windows systems. We can use it to configure LAMP/LNMP environments, websites, databases, FTP, etc. with one click, and easily manage servers through the Web.

In the following tutorial, we will demonstrate how to use the Pagoda panel to quickly and easily build a local web site, and perform intranet penetration so that users who are not on the same LAN can also access the local web site without the need for a public IP or setting up a router.

1. Environment installation

To install the apache server, we click on the website in the pagoda panel, and then we will be prompted to install the apache server.

image-20230307143843485

Choose quick installation

image-20230307155129355

Then wait for the installation to be completed. When the installation is completed, a message list will appear on the left.

image-20230307155221216

2. Install cpolar intranet penetration

https://www.cpolar.com/

  • Open the Pagoda Terminal command window and use the cpolar installation script:
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash

image-20230303183721806

  • token authentication

Log in to the cpolar official website, click on the left side验证 to view your authentication token, and then paste the token into the command line

cpolar authtoken xxxxxxx

20230111103532

  • Add services to the system
sudo systemctl enable cpolar
  • Start cpolar service
sudo systemctl start cpolar
  • Open port 9200

Select security in the Pagoda panel. Then open port 9200

image-20230303184430176

  • Log in to the cpolar web UI management interface

Then access the LAN IP to port 9200 and the cpolar management interface will appear. Enter your cpolar email account to log in.

image-20230303184618711

3. Intranet penetration

After logging in to the cpolar web UI management interface, we create an http tunnel pointing to port 80, because the default apache service is port 80

  • Tunnel name: Customizable, be careful not to repeat it
  • Protocol: http
  • Local address: 80
  • Port type: random domain name
  • Region: China vip

Click创建

image-20230307161358154

After the creation is successful, we open the online tunnel list and copy the created public network address.

image-20230307161716775

Then we open the Pagoda panel, click on the website, select Add Site, paste the copied public network address into the parameter box of the domain name, and then click Submit

image-20230307162110990

At this time we can see that the site was created successfully

image-20230307162248903

Then we use the copied public network address, open the browser to access, and the welcome page appears to indicate success.

image-20230307163357047

4. Fixed http address

Since the tunnel just created uses a random temporary address, the address will change within 24 hours. For long-term remote access, we next configure this public network address as fixed.

You need to upgrade to the basic package or above to support the configuration of second-level subdomain names.

Log in to the cpolar official website backend, click 预留 on the left dashboard, find 保留二级子域名, and reserve a second-level subdomain name for the http tunnel.

  • Region: Select server region
  • Name: Fill in the second-level subdomain name you want to reserve (can be customized)
  • Description: Notes, which can be customized

image-20230307164936590

This example reserves a second-level subdomain namedmywebsitegame. After the subdomain name is successfully reserved, we copy the subdomain name and then configure it into the tunnel.

image-20230307165346945

5. Configure the second-level subdomain name

Log in to the cpolar web ui management interface. Click 隧道管理——隧道列表 on the left dashboard, find the tunnel that needs to configure the second-level subdomain name (in this case, the apache website tunnel), and click on the right 编辑

image-20230307165440111

Modify the tunnel information and configure the second-level subdomain name into the tunnel:

  • Domain Type: Select instead二级子域名
  • Sub Domain: Fill in the second-level subdomain name we just reserved (in this case mywebsitegame)

After modification is completed, click更新

image-20230307165524932

After the tunnel is updated successfully, click 状态——在线隧道列表 on the left dashboard. You can see that the public network address of the tunnel has been updated to 2 level subdomain name, copy the public network address.

image-20230307165845253

Then we open the Pagoda panel, find the site, and click Settings

image-20230307170712990

Add a fixed public address domain name

image-20230307170900973

Then delete the random address created before

image-20230307170948787

Then we open the browser and use the fixed public network address to access. Above we have configured the site remote access.

image-20230307172031135

6. Create a test page

Click the site root directory path and click directly

image-20230307172438126

Create a new page named game.html

image-20230307172627027

Then double-click the file to edit, copy the following code into it (Snake mini game), and then Ctrl+S to save

<!DOCTYPE html>
<html>
<head>
	<title>贪吃蛇</title>
	<meta charset="UTF-8">
	<meta name="keywords" content="贪吃蛇">
	<meta name="Description" content="这是一个初学者用来学习的小游戏">
	<style type="text/css">
	*{
      
      margin:0;}
	.map{
      
      margin:100px auto;
		height:600px;
		width:900px;
		background:#00D0FF;
		border:10px solid #AFAEB2;
		border-radius:8px;
	}
	</style>
</head>
 
<body>
<div class="map">
<canvas id="canvas" height="600" width="900">
	
</canvas>
</div>
 
<script type="text/javascript">
 //获取绘制工具
	/*
	var canvas = document.getElementById("canvas");
	var ctx = canvas.getContext("2d");//获取上下文
	ctx.moveTo(0,0);
	ctx.lineTo(450,450);*/
	var c=document.getElementById("canvas");
    var ctx=c.getContext("2d");
    /*ctx.beginPath();
    ctx.moveTo(0,0);
    ctx.lineTo(450,450);
    ctx.stroke();
    */
 
    var snake =[];//定义一条蛇,画蛇的身体
    var snakeCount = 6;//初始化蛇的长度
	var foodx =0;
	var foody =0;
    var togo =0;
    function drawtable()//画地图的函数
    {
      
      
 
 
    	for(var i=0;i<60;i++)//画竖线
    	{
      
      
    		ctx.strokeStyle="black";
    		ctx.beginPath();
    		ctx.moveTo(15*i,0);
    		ctx.lineTo(15*i,600);
    		ctx.closePath();
    		ctx.stroke();
    	}
        for(var j=0;j<40;j++)//画横线
    	{
      
      
    		ctx.strokeStyle="black";
    		ctx.beginPath();
    		ctx.moveTo(0,15*j);
    		ctx.lineTo(900,15*j);
    		ctx.closePath();
    		ctx.stroke();
    	}
    	
    	for(var k=0;k<snakeCount;k++)//画蛇的身体
			{
      
      
			ctx.fillStyle="#000";
			if (k==snakeCount-1)
			{
      
      
				ctx.fillStyle="red";//蛇头的颜色与身体区分开
			}
			ctx.fillRect(snake[k].x,snake[k].y,15,15);//前两个数是矩形的起始坐标,后两个数是矩形的长宽。
			
			}
			//绘制食物	
    		ctx.fillStyle ="black";
	     ctx.fillRect(foodx,foody,15,15);
	     ctx.fill();
    	
    }
 
    
    function start()//定义蛇的坐标
    {
      
      
    	//var snake =[];//定义一条蛇,画蛇的身体
        //var snakeCount = 6;//初始化蛇的长度
		
		for(var k=0;k<snakeCount;k++)
    		{
      
      
    			snake[k]={
      
      x:k*15,y:0};
    			
            }
			
		  drawtable();
          addfood();//在start中调用添加食物函数
 
    }
 
    function addfood()
	{
      
      
	foodx = Math.floor(Math.random()*60)*15; //随机产生一个0-1之间的数
	foody = Math.floor(Math.random()*40)*15;
		
		for (var k=0;k<snake;k++)
		{
      
      
			if (foodx==snake[k].x&&foody==sanke[k].y)//防止产生的随机食物落在蛇身上
			{
      
      	
			addfood();
			}
		}
	
	
	}	
    		
   function move()
   {
      
      
	switch (togo)
	{
      
      
	case 1: snake.push({
      
      x:snake[snakeCount-1].x-15,y:snake[snakeCount-1].y}); break;//向左走
	case 2: snake.push({
      
      x:snake[snakeCount-1].x,y:snake[snakeCount-1].y-15}); break;
	case 3: snake.push({
      
      x:snake[snakeCount-1].x+15,y:snake[snakeCount-1].y}); break;
	case 4: snake.push({
      
      x:snake[snakeCount-1].x,y:snake[snakeCount-1].y+15}); break;
	case 5: snake.push({
      
      x:snake[snakeCount-1].x-15,y:snake[snakeCount-1].y-15}); break;
	case 6: snake.push({
      
      x:snake[snakeCount-1].x+15,y:snake[snakeCount-1].y+15}); break;
	default: snake.push({
      
      x:snake[snakeCount-1].x+15,y:snake[snakeCount-1].y});
	}
    snake.shift();//删除数组第一个元素
   	ctx.clearRect(0,0,900,600);//清除画布重新绘制
   	isEat();
	isDead();
	drawtable();
   } 			
   
   function keydown(e)
   {
      
      
   switch(e.keyCode)
		{
      
      
         case 37: togo=1; break;
		 case 38: togo=2; break;
		 case 39: togo=3; break;
		 case 40: togo=4; break;
		 case 65: togo=5; break;
		 case 68: togo=6; break;
		}
   }
   
   function isEat()//吃到食物后长度加1
   {
      
      
    if(snake[snakeCount-1].x==foodx&&snake[snakeCount-1].y==foody)
   {
      
      
		addfood();
		snakeCount++;
		snake.unshift({
      
      x:-15,y:-15});
   }
   
   }
   //死亡函数
   function isDead()
   {
      
      
    if (snake[snakeCount-1].x>885||snake[snakeCount-1].y>585||snake[snakeCount-1].x<0||snake[snakeCount-1].y<0)
		{
      
      
        

		window.location.reload();
		}
   }
   
    document.onkeydown=function(e)
{
      
      
	keydown(e);
 
} 
window.onload = function()//调用函数
{
      
       
	start();
	setInterval(move,150);
	drawtable();
	
	
 
}
</script>
</body>
</html>

image-20230307172848766
Then our browser uses the public network address and adds this html file to access, and we can see the mini-game we deployed.

image-20230307173606348

Guess you like

Origin blog.csdn.net/bushibrnxiaohaij/article/details/134929925