Home >Operation and Maintenance >Nginx >How to configure nginx to ensure that the frps server and web share port 80

How to configure nginx to ensure that the frps server and web share port 80

WBOY
WBOYforward
2023-06-03 08:19:081239browse

First of all, you will have a doubt, what is frp? Simply put, frp is an intranet penetration tool. After configuring the client, you can access the intranet through the server.

Now my server has been built with nginx, and there is only one port 80. So what should I do if the frp server also wants to use port 80?

After querying, this can be achieved by using nginx's reverse proxy.

To add: frps is the server (server), frpc is the client (client).

Step one: Modify the nginx.conf configuration file in the server

Add the following parameters in http{ } in nginx.conf,

server {

  listen 80;

  server_name xiaoyue.ml www.xiaoyue.ml;

  location / {

   proxy_pass http://127.0.0.1:8080;

   proxy_redirect http://$host/ http://$http_host/;

   proxy_set_header x-real-ip $remote_addr;

   proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;

   proxy_set_header host $host;

  }

}

As shown below, save the settings and restart nginx

How to configure nginx to ensure that the frps server and web share port 80

Step 2: Modify the frp server configuration file

Since the reverse proxy has reached port 8080, the configuration file of the frp server also needs to be set

vhost_http_port = port 8080 in the frps.ini configuration file

How to configure nginx to ensure that the frps server and web share port 80

The third step: Modify the frp client configuration file

The first step is configuring: server_name xiaoyue.ml www.xiaoyue.ml; Fill in the corresponding domain name here.

also supports pan-parsing, for example: server_name *.xiaoyue.ml; the domain name needs to be pan-parsed at the same time.

So how to modify frpc.ini, it’s very simple

Configure the corresponding domain name in the corresponding penetration service configuration, custom_domains = xiaoyue.ml

How to configure nginx to ensure that the frps server and web share port 80

Step 4:

Restart frps on the server, start frpc on the local computer, and you can pass 80 in the browser The port directly accesses xiaoyue.ml.

How to configure nginx to ensure that the frps server and web share port 80

Additional 1:

xiaoyue.ml is parsed to my server, and this website is built in the LAN in my own computer.

That is to say, first make sure that you access 127.0.0.1 on your computer and there is content.

Additional 2:

The reverse proxy in the first step can also be done like this

Pagoda background

1) Website -->Add a site, enter your domain name

For example, enter the added domain name xiaoyue.ml Submit

2) Click Settings-->Reverse proxy

Target Fill in http://127.0.0.1:8080 in the url, please do not enter the wrong

Choose to enable reverse proxy

ps: Are you a little confused? . .

In fact, the core of this article is just one step, which is to reverse proxy to xiaoyue.ml:8080 port when you visit xiaoyue.ml (by default, we access the website through port 80).

Then what’s the point of doing this? I just want to access the website directly through the domain name instead of accessing the website through the domain name:port number.

The above is the detailed content of How to configure nginx to ensure that the frps server and web share port 80. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete