Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Implementation of IPv6 proxy IPv4web by nginx reverse proxy

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. When the environment is ready, download the installation package

Enter a directory (any directory can be used to store the downloaded Nginx installation package, here take the / root directory as an example)

Enter directory command: cd / root

Download the nginx installation package and use case nginx-1.16.0 for this article (the latest version can be viewed on the official website-http://nginx.org/download)

Download command: wget http://nginx.org/download/nginx-1.16.0.tar.gz

2. Decompress the tar package of Nginx

Decompression command: tar-zxvf. / nginx-1.16.0.tar.gz

3. Check whether the decompression is successful.

Command: ls

4. Enter the directory that has just been extracted

Command: cd nginx-1.16.0

Configure (here point the Nginx installation to the / usr/local/nginx/ directory)

Command:. / configure-- prefix=/app/nginx/

5, compile and install

Command: make & & make install

6, the entire verification, compilation, installation process should not report any errors, if in the previous process using prefix to set the installation target directory, then you also need to set environment variables in the / etc/profile file (Note: environment variables generally refer to the operating system used to specify some parameters of the operating system running environment, equivalent to setting a startup software (such as mysql/jdk) and other fast path to facilitate users to use. )

Command: vi / etc/profile

Add export PATH=/app/nginx/sbin:$PATH at the end (where # add nginx path is recommended for comments)

7 to make the environment variable effective

Command: source / etc/profile

8. Check the environment variables with the command export and find that the Nginx directory you just set has been successfully entered

9, check whether the installation is successful:

Go to the etc directory (cd / etc) and execute the command: nginx-t. If it is incorrect, it will give the corresponding error prompt.

10. Configure the Nginx configuration file. The location of the Nginx configuration file is: / app/nginx/conf/nginx.conf (the specific location depends on your own. If you don't know where the configuration file is placed, you can use xftp to view it), and use the vi command to edit:

Vi / usr/local/nginx/conf/nginx.conf

11, modify the configuration file to nginx.conf in conf under the Nginx installation directory, command:

/ usr/local/nginx/sbin/nginx-c / app/nginx/conf/nginx.conf

12, start nginx, command:

Nginx

13. Check the Nginx status, command:

Ps-ef | grep nginx

14. When Nginx is started, access the address just configured in the configuration file with the browser externally. As shown in the figure, it is successful.

Possible problems:

When using a browser externally, the access address may not be accessible.

Cause of the problem: Port 80 is not open, or the firewall is not turned off

Based on security considerations, it is recommended to open port 80.

1, open port 80 (please note that make sure the firewall is on at this time, otherwise there is no point in doing this step):

View the open port command in the firewall-iptables-L

Open a port (take 80 as an example) to firewall-cmd-- zone=public-- add-port=80/tcp-- permanent

Restart the firewall: systemctl restart firewalld.service

2. Turn off the firewall:

Service firewalld stop

Just choose one of these two operations. At this point, the Nginx installation tutorial is over.

Compile the nginx.conf file in the nginx installation package as follows:

Http {

Upstream ipv6 {# ipv6 is the name of the upstream server created by yourself

Server 1.1.1.1IP 80; # 1.1.1.1 is the IP address of the real IPv4 website

}

……

……

……

Server {

Listen 80 default_server; listen [:]: 80 default_server; # add this command, that is, listen to the url of port 80 server_name xxxx.yyyy.edu.cn; # IPv4 of all IPv6

……

……

……

Location / {

Proxy_pass http://ipv6; # all red colors in this section are added and need to be associated with upstream and server information proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; root html; index index.html index.htm;}

After the installation is complete, enable the nginx service for testing.

Adding multiple agents is configured as follows:

Http {

Map $host $upstream {www.aaaa.edu.cn 1.1.1.1 upstream 80; www.bbbb.edu.cn 2.2.2.2 upstream 80; www.cccc.edu.cn 3.3.3.3

Include mime.types

Default_type application/octet-stream

# log_format main'$remote_addr-$remote_user [$time_local] "$request"'

'$status $body_bytes_sent "$http_referer"' "$http_user_agent"$http_x_forwarded_for"'

# access_log logs/access.log main

Sendfile on

# tcp_nopush on

# keepalive_timeout 0

Keepalive_timeout 65

# gzip on

Server {

Listen 80; listen [:]: 80; server_name www.aaaa.edu.cn; location / {proxy_pass http://www.aaaa.edu.cn; # Shanghai Civil Aviation Professional proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $http_x_forwarded_for; root html; index index.html index.htm;}

}

Server {

Listen 80; listen [:]: 80; server_name www.bbbb.edu.cn; location / {proxy_pass http://www.bbbb.edu.cn; # Shanghai Publishing and Printing proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $http_x_forwarded_for; root html; index index.html index.htm;}

}

Server {

Listen 80; listen [:]: 80; server_name www.cccc.edu.cn; location / {proxy_pass http://www.cccc.edu.cn; # Shanghai Agriculture and Forestry occupation proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $http_x_forwarded_for; root html; index index.html index.htm;}

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report