frp configure multiple web projects, without having to buy a domain name
Simple configuration, reference
Preface:
There are many online tutorials include official documents , need to purchase a domain name, and the value frpc.ini the [web] section of the configuration of custom_domains resolve to external network server, multiple web projects require multiple custom_domains (guaranteed to be unique for each web project ), all these custom_domains resolve to the external network server, then you can use, use is custom_domains: vhost_http_port, you can achieve access multiple web projects.
The following method does not need to purchase a domain name and domain name resolution services, can also be achieved within the network through the use of multiple web projects
Propose solutions based on the principle of (want to quickly resolve the problem, skip)
Question : frp software Although the configuration of custom_domains, but all resolve to the same external network server, why can fulfill the request unified port (frps.ini common in vhost_http_port ) to achieve access different web project needs it?
1. First of all, we all know that your browser and enter a url to access the process, if it is using a domain name, you first need to resolve domain names to get the real IP address is then sent through TCP packet. So magical place to come, we frpc.ini in all the custom_domains web project are resolved to the same IP address and port frps.ini provide web access is only one (vhost_http_port), to establish a connection in accordance with the socket, we With (IP, Port) this tuple, uniquely identifies this connection, so we can conclude that all the configuration of the network of web projects are all completed using this socket
2. Use a socket that links how to distinguish between different web projects within the network do?
Recall frpc.ini, we are here to configure different custom_domains, this is the key, fpr server only through the distribution of different data in order to identify the different web projects. Therefore, we adopted custom_domains: vhost_http_port time to access the destination web project, necessary to ensure custom_domains be delivered to the frp server, so as to be distributed. frp software uses the host field http to ensure that this matter , when we use the browser requests a target site, the browser automatically purposes RUL domain name of the host to http request header field. Therefore, when the request arrives frp server, as long as you can by looking for web projects and corresponding request header host, thus achieving a question port distribution. (Nginx similar distribution in port, but there url prefix for distribution, request header host field is used here)
3. See here you will understand how to do it (laughs)
As long as we configured the machine's host file, append each custom_domains to resolve to a public server
By this way we can achieve, custom_domains was successfully placed header host field of the request, and does not need to buy a domain name for local resolution.
=========== practice to send ==============
A disposed frpc.ini [Common] The server_addr = xx.xx.xx.xx
[common]
server_addr = xx.xx.xx.xx
server_port = 7000
[ssh_sx] of the type = tcp local_ip = 127.0 . 0.1 local_port = 22 remote_port = 6001 [web_9990] of the type = HTTP local_ip = 127.0 . 0.1 local_port = 9990 # site is using the port custom_domains = A. as Free .domain # just write guarantee a unique domain name [web_9991] of the type = HTTP local_ip = 127.0 . 0.1 local_port = 9991 # port sites use
custom_domains = b. as Free .domain # just write guarantee a unique domain name
Second, the configuration server frps.ini
[common] bind_port = 7000 vhost_http_port = 8080
Second, restart the client software ./frpc -c frpc.ini restart the server software ./frps -c frps.ini
Third, the local host configuration file
windows : C:\Windows\System32\drivers\etc\hosts
linux: /etc/hosts
add to
xx.xx.xx.xx a.free.domain xx.xx.xx.xx b.free.domain
xx.xx.xx.xx is your public IP address of the server
Refresh host file, so that the new configuration to take effect :
windows: ipconfig.exe /flushdns
linux: systemctl restart nscd
Fourth, open your browser
Input: a.free.domain: 8080 to access the web project web_9990
Input: b.free.domain: 8080 to access the web project web_9991
custom_domains