# Public network access macOS local web server [Intranet penetration]
Article directory
-
-
-
- 1. Start the Apache server
- 2. Access local web services from the public network
- 2.1 Local installation and configuration of cpolar
- 2.2 Create tunnel
- 2.3 Test access to public network address
- 3. Configure a fixed second-level subdomain name
- 3.1 Reserve a second-level subdomain name
- 3.2 Configure the second-level subdomain name
- 4. Test access to the fixed second-level subdomain name of the public network
-
-
Taking the Apache that comes with macOS as an example, enable the apache server locally and expose it to the public network through cpolar intranet penetration to enable access to local web services in the public network environment.
1. Start the Apache server
Open the terminal on macOS and execute the command to start the Apache server. It will prompt Passwod
and enter the password.
sudo apachectl start
## Common Apache commands: ## Start apache: sudo apachectl start ## Restart apache: sudo apachectl restart ## Shut down apache: sudo apachectl stop
The browser accesses localhost (default port 80), and the page displays It Works!
, indicating that the server started successfully and can be accessed normally within the LAN!
2. Access local web services from the public network
At present, web services can only be accessed within the LAN. Next, we use cpolar intranet penetration to map the local web services to the public network, so that public network users can also access the local web services without the need for a public network IP or setting up a router.
2.1 Local installation and configuration cpolar
Download the zip package suitable for macOS platform from the official website, unzip it to get cpolar, and then run it with parameters through the command line.
- Install via Homebrew package manager
brew tap probezy/core & amp; & amp; brew install cpolar
- token authentication
Log in to the cpolar official website backend, click Verify on the left, check your authentication token, and then paste the token in the command line
cpolar authtoken xxxxxxx
- install service
sudo cpolar service install
- Start service
sudo cpolar service start
- Log in to the cpolar web UI management interface
Access the local port 9200 [http://127.0.0.1:9200/] on the browser and log in using the cpolar account.
After successfully logging in, click Tunnel Management – Tunnel List on the left dashboard. You can see two sample tunnels (you can edit or delete them yourself)
- ssh tunnel: pointing to local port 22, tcp protocol
- website tunnel: pointing to local port 8080, tcp protocol
2.2 Create tunnel
Click Tunnel Management – Create Tunnel on the left dashboard. Let’s create a tunnel to map the web service under local port 80 to the public network:
- Tunnel name: Customizable, be careful not to duplicate the name of an existing tunnel
- Protocol: http protocol
- Local address: 80
- Domain name type: Choose a random domain name for free
- Region: Select China VIP
Click Create
After the tunnel is successfully created, the page automatically jumps to the tunnel list. You can see the tunnel-1 tunnel that was just created successfully. The status is active
, which means it is normally online. Note that there is no need to click to start again.
Click on the status of the dashboard on the left – online tunnel list. You can see that the tunnel-1 tunnel has generated a corresponding public network address, an http protocol and an https protocol (avoiding the tedious steps of configuring the SSL certificate). Both are available. Access the local web service and copy the public address.
2.3 Test access to public network address
Access the public network address on the browser, test the access successfully, and realize the public network access to the local web service.
3. Configure a fixed second-level subdomain name
Since the public network address generated by using free cpolar is a random temporary address and will change within 24 hours, it is not very convenient for users who need long-term access. To this end, we can configure it with a fixed second-level subdomain name that is easy to remember, while increasing the bandwidth and achieving smoother access.
Note that you need to upgrade the cpolar package to the basic package or above. [cpolar.cn has been registered]
3.1 Reserve a second-level subdomain name
Log in to the cpolar official website backend, click Reserve on the left, and find the reserved second-level subdomain name:
- Region: Select China VIP
- Second-level domain name: can be customized
- Description: Notes, which can be customized
Click Keep
Prompt that the subdomain name is reserved successfully, copy the reserved second-level subdomain name
3.2 Configure second-level subdomain names
Visit http://127.0.0.1:9200/ to log in to the cpolar web UI management interface, click Tunnel Management – Tunnel List on the left dashboard, find the tunnel you want to configure, and click Edit
on the right
Modify the tunnel information and configure the successfully reserved second-level subdomain name into the tunnel.
- Domain name type: Select
Second-level subdomain name
- Sub Domain: Fill in the second-level sub-domain name that was successfully reserved, in this case
test01
Click Update
It will prompt that the tunnel update is successful. Click the status on the left dashboard – Online tunnel list. You can see that the public network address has been updated to the second-level subdomain name that has been successfully reserved. Copy it.
4. Test access to the fixed second-level subdomain name of the public network
Access the fixed second-level subdomain name on the browser, and the test access is successful. Now the public network address will not change randomly.
If you want to use your own domain name to access local web services, cpolar also supports this function. For details, please refer to the next article tutorial:
- Configure your own domain name for the local web service