A configuration .window10
1. Download nginx
First enter http://nginx.org/en/download.html download, bloggers are using 1.15.7, is a relatively new version, which can be downloaded according to everyone's needs.
2. Create a folder parsing the configuration vhost
Open the conf folder, find nginx.conf file open, you will find a lot of writing, very complicated. If we then write in the source file, then of course it can, but for the future expansion of the project, the second development, the bloggers do not recommend you do it, because it not only looks messy, it is not easy to modify, giving It does not feel good, so bloggers are here to provide a more scientific and rational preparation of the program, for your reference and use.
1. Create a new folder vhost (under the folder in the conf file)
Here I want to explain why you want to create a folder:
1) The code structure is simple, in line with the development of contemporary forms
2) to facilitate the development of secondary code their duties, but also easy to modify the code
3. introduction vhost
Now that we have created a folder of course use the vhost, use the Text tool to open nginx.conf compiled in the same directory, find a suitable location to add the following line of code:
The purpose of adding this code can be understood as a simple, nginx.conf the main configuration file you want to be lazy, so as employers hired many workers to their work, where the * .conf the workers, that is, we are going to write reverse DNS proxy configuration file.
Here I would like to give two simple examples:
1. To achieve the reverse proxy domain name
Because the requirements vhost directory under the file name suffix named conf, so I created the following file. ( Note : Do not use tools to edit the file Notepad, or nginx compiler error occurs, bloggers come across)
Requirement is to own the domain name specified activate.navicat.com can be forwarded to 127.0.0.1:8080 page, which is accessible tomcat main page
Configuration details are as follows:
server {
listen 80; # 监听 80 端口
autoindex on;
server_name activate.navicat.com; //访问域名
access_log logs/host.access.log combined; //日志文件位置
index index.html index.htm index.jsp index.php; //前端页面显示优先级
if ( $query_string ~* ".*[\;'\<\>].*" ){
return 404;
}
location / {
proxy_pass http://127.0.0.1:8080; # 反向代理到 8080 端口
add_header Access-Control-Allow-Origin *;
}
}
Then configure the local hosts file and map server_name
The last line in the hosts file to add a line statement:
127.0.0.1 activate.navicat.com
Here method to save the hosts file can not exist, can not save search on the Internet after the hosts file modifications, where good blogger also provide some links for you:
https://jingyan.baidu.com/article/624e7459b194f134e8ba5a8e.html
Well, everything is in place only a strong wind, we first start up tomcat, to ensure that we have access to local, ok
Then start nginx, there are two ways to start a command-line way to start a double-click on it to start, but I still recommend the first approach.
Determine our nginx boot is completed, we can test whether our successful configuration
It was found that you're done, reverse domain name proxy successful.
2. To achieve the image server set up
It is required to access their specified domain activate.images.com / Image Name able to access the local disk images
Because the requirements vhost directory under the file name suffix named conf, so I created the following file.
Configuration details are as follows:
server {
listen 80; #监听 80 端口
autoindex off;
server_name activate.images.com; #请求域名
access_log logs/host.access.log combined; #日志文件存放的位置
index index.html index.htm index.jsp index.php; #前端页面显示的优先级
if ( $query_string ~* ".*[\;'\<\>].*" ){
return 404;
}
location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* {
deny all;
}
location / {
root G:\ftpfile\img; #本地图片存放的路径,保证本地磁盘存在该目录,且目录存在你想要访问的图片
add_header Access-Control-Allow-Origin *;
}
}
Then configure the local hosts file and map server_name
The last line in the hosts file plus line statement:
activate.images.com
Then restart nginx
.. With the passage of time,
These are the window10 configure a reverse proxy server and DNS server configuration picture of the way.
Two .Centos7 configuration
1: Preparing the environment
1.首先安装虚拟机下载centos7镜像进行安装,条件允许的情况下可以考虑购买某云服务器。
2.配置centos7,建议自行百度
3.安装jdk环境,推荐https://blog.csdn.net/qq_42815754/article/details/82968464
4.安装tomcat,推荐https://www.cnblogs.com/yw-ah/p/9770971.html
5.安装nginx,推荐https://www.cnblogs.com/xxoome/p/5866475.html
2.创建解析配置文件夹vhost
找到nginx的根目录,找到conf文件夹,跟window10操作类似再conf文件夹下创建vhost文件夹,方便编写接下来操作的配置文件。
3.引入vhost
和window10类似,也是在nginx.conf文件中加入引入语句
实现window10上面的实现的功能我依然要创建两个后缀名如下的配置文件
紧接着配置本地hosts文件与server_name进行映射,这里是和window有差距的,首先找到hosts文件所在的位置,然后进行编写。
配置好保存之后,一定要做的一件事(重启网络才能生效)
/etc/init.d/network restart
最后启动tomcat,nginx就能访问到你想要看到的结果了
以上就是window10配置反向代理服务器域名解析和配置图片服务器的方式。
最后博主抓住19年的小尾巴,在腊月二十八的夜晚,祝大家在新的一年万事胜意,Easy coding!