By using Nginx virtual domain name configuration, you can access the local server through a specific domain name without purchasing a domain name. Reduce unnecessary pre-launch expenses. Configuration steps 1. Edit the nginx.conf configuration file (1) Add the domain name to the file name (for easy management in the future) The following code is added under the http node of nginx.conf. But you need to pay attention to the path of the vhost folder. The path of the vhost folder created here is: /usr/local/nginx/Nginx/conf/vhost, but nginx.conf is in /usr/local/nginx/conf/nginx.conf. Pay attention to the path setting. (2) Save and exit Use vim's ":wq" command to save and exit. If you are still in editing mode, you need to press the Esc key first and then enter the command. 2. Configure domain name forwarding (1) Create a vhost folder in the installation directory (2) Create and edit domain forwarding configuration files # www.huaiangg.com is the domain name you want to customize, add the suffix .vonf and you can vim /usr/local/nginx/Nginx/conf/vhost/www.huaiangg.com.conf In the vim editor, copy the following code into it. server { listen 80; autoindex on; # This is the domain name you want to set server_name www.huaiangg.com; access_log /usr/local/nginx/logs/access.log combined; index index.html index.htm index.jsp index.php; #error_page 404 /404.html; if ( $query_string ~* ".*[\;'\<\>].*" ){ return 404; } location / { # Here, set the reverse proxy to Tomcat's access path proxy_pass http://127.0.0.1:8080/; add_header Access-Control-Aloow-Origin *; } } Save and exit. Use vim's ":wq" command to save and exit. If you are still in editing mode, you need to press the Esc key and then enter the command. 3. Set hosts settings The hosts under Linux are in /etc/hosts. Use vim to open the corresponding path. Configure related domain names #centos # Reverse proxy--> tomcat address 192.168.197.130 www.huaiangg.com # Image hosting 192.168.197.130 iamge.huaiangg.com # Front-end and back-end separation server 192.168.197.130 s.huaiangg.com Save and exit. Use vim's ":wq" command to save and exit. If you are still in editing mode, you need to press the Esc key and then enter the command. 4. Start (restart) verification Note: ${nginx} represents the default installation path of the system, for example: /usr/local/nginx/ (1) Start (2) Restart 5. Access Verification Use the default port for authentication. If the port is occupied, modify the default access port in nginx.conf. http://localhost:80 or http://127.0.0.1:80 5. Testing Just enter the address of the reverse proxy in the browser in the Linux environment, for example: www.huaiangg.com, see below for details: Summarize The above is the virtual domain name configuration and test verification under the Linux\Nginx environment introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Does MySql need to commit?
>>: Detailed explanation of JavaScript closure issues
Preface This control will have a watermark at the...
Question 1: How do you instruct the browser to dis...
Mapping the mouse position or implementing drag e...
1. Download the mysql tar file: https://dev.mysql...
I want to make a page using CSS3 rounded corners ...
TypeScript Bundling webpack integration Usually, ...
Copy code The code is as follows: <meta name=&...
Table of contents Brief Introduction setInterval ...
Two parameters of Mysql paging select * from user...
The input box always displays the input history wh...
Counting the size of each table in each database ...
The DATE_ADD() function adds a specified time int...
1. Write Shell script crontab.sh #!/bin/bash step...
Table of contents Problem scenario: Solution: 1. ...
This article shares the specific code for impleme...