Today, I studied FRP on Alibaba Cloud Server. Because it has been filed, I plan to change the HTTP port in FRP to 80 port. However, the server has set up other websites to change 80 port, so I plan to share 80 port through nginx.

Implementation steps:
The deployed port 80 does not need to be changed, but only needs to add an nginx configuration *.frp.51it.wang If all 80's are forwarded to port 88, you can access port 88 on the FRP after accessing port 80 (http in my deployed FRP is port 88)

The core configuration of nginx is as follows:

 server { listen 80; server_name *.frp.51it.wang; #Blocking and forwarding location / { proxy_intercept_errors on; proxy_pass  http://127.0.0.1:88 ; proxy_set_header    Host            $host:80; proxy_set_header    X-Real-IP       $remote_addr; proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for; proxy_hide_header   X-Powered-By; } access_log  /home/xx.log; error_log  /home/error.log; }

Then restart nginx to try the effect, and 80 can coexist.


Remaining problems:
However, I want to change the default error page of FRP to a customized page, intercepting 404 and other errors to the customized page. Although it has been implemented, I still don't know how to solve a problem.
After the change, the browser has been redirected to the error page, resulting in the inability to access the page. The nginx log has also printed a lot of redirect errors. It is estimated that some places are not set correctly - first paste it to see if there is any big guy to solve it, ha ha ha.

The page error is as follows:
 Nginx implements coexistence of port 80 and FRP

The background log error is as follows:
 Nginx implements coexistence of port 80 and FRP

My nginx configuration is as follows:

 server { listen 80; server_name *.frp.51it.wang; #Error page configuration error_page  404 404.html; location = /404.html { root       /home/www; } #Blocking and forwarding location / { proxy_intercept_errors on; proxy_pass  http://127.0.0.1:88 ; proxy_set_header    Host            $host:80; proxy_set_header    X-Real-IP       $remote_addr; proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for; proxy_hide_header   X-Powered-By; } access_log  /home/xx.log; error_log  /home/error.log; }

At present, only 404 pages are not customized.