In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Application scenario 1: www.accp.com-the old domain name of the jump company based on domain name, due to changes in business requirements, we need to use a new domain name www.kgc.com instead of not abolishing the old domain name to jump from the old domain name to the new domain name, and keep its parameters unchanged the experimental environment Linux server (192.168.13.144) test machine win71 Install Nginx service [root@localhost ~] # rpm- Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm## install nginx official source warning: / var/tmp/rpm-tmp.vS0k20: header V4 RSA/SHA1 Signature Key ID 7bd9bf62: NOKEY in preparation. # # [100%] upgrading / installing... 1:nginx-release-centos-7-0.el7.ngx # # # [root@localhost] # yum install nginx-y # # yum install nginx2 Modify nginx default configuration file [root@localhost ~] # vim / etc/nginx/conf.d/default.conf # # modify default configuration file server {listen 80 Server_name www.accp.com; # # modify hostname # charset koi8-r; access_log / var/log/nginx/www.accp.com-access.log main # # enable log service 3, install bind resolution service [root@localhost ~] # yum install bind-y4, modify the main configuration file (named.conf) [root@localhost ~] # vim / etc/named.conf options {listen-on port 53 {any;}; # # listen on all listen-on-v6 port 53 {:: 1;} Directory "/ var/named"; dump-file "/ var/named/data/cache_dump.db"; statistics-file "/ var/named/data/named_stats.txt" Memstatistics-file "/ var/named/data/named_mem_stats.txt"; recursing-file "/ var/named/data/named.recursing"; secroots-file "/ var/named/data/named.secroots"; allow-query {any;} # # allow all 5. Modify the zone configuration file (named.rfc1912.zones) [root@localhost ~] # vim / etc/named.rfc1912.zones # # configure the zone configuration file zone "accp.com" IN {type master; file "accp.com.zone" # # accp region data configuration file allow-update {none;};} 6. Modify the zone data configuration file (accp.com.zone) [root@localhost ~] # cd / var/named/ [root@localhost named] # cp-p named.localhost accp.com.zone # # copy template [root@localhost named] # vim accp.com.zone # # modify the zone configuration file $TTL 1D @ IN SOA @ rname.invalid. (1D; refresh 1H; retry 1W Expire 3H) Minimum NS @ A 127.0.0.1www IN A 192.168.13.144 # # Local address [root@localhost named] # systemctl start named # # enable the dns service [root@localhost named] # systemctl stop firewalld.service # # turn off the firewall [root@localhost named] # setenforce 0 [root @ localhost named] # systemctl start nginx # # enable the nginx service [root@localhost named] # netstat-ntap | grep nginx # # View port tcp 0 0 0.0 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. Test the web page with a testing machine
8. Modify the configuration file, set the domain name redirection [root@localhost named] # vim / etc/nginx/conf.d/default.conf # # modify the configuration file server {listen 80; server_name www.accp.com; # charset koi8-r; access_log / var/log/nginx/www.accp.com-access.log main Location / {if ($host = "www.accp.com") {# # match if the domain name is the old domain name rewrite ^ / (. *) $http://www.kgc.com/$1 permanent; # # then permanently set the jump to the new domain name} root / usr/share/nginx/html Index index.html index.htm;} 9, add new domain name resolution [root@localhost named] # vim / etc/named.rfc1912.zones zone "kgc.com" IN {type master; file "kgc.com.zone" # # accp region data configuration file allow-update {none;};} [root@localhost named] # cp-p / var/named/accp.com.zone / var/named/kgc.com.zone## replication zone data configuration file is the data configuration file of kgc [root@localhost named] # systemctl restart named # # restart the resolution service [root@localhost named] # systemctl restart nginx # # restart nginx service 10, access with the old domain name, and view the jump
11. Add parameters to the old domain name to see if there are parameters when you jump to the new domain name
Application scenario 2 IP-based on client IP access to jump company business version online, all IP access anything shows a fixed maintenance page, only company IP access normal 1, modify Nginx default configuration file [root@localhost ~] # cd / etc/nginx/conf.d/ [root@localhost conf.d] # vim default.conf server {listen 80; server_name www.accp.com; # charset koi8-r Access_log / var/log/nginx/www.accp.com-access.log main; # sets the legal IP flag set $rewrite true; # # sets the variable to true # determines whether it is a legitimate IP if ($remote_addr = "192.168.13.140") {set $rewrite false # # match legal IP, set variable to false, normal jump page} # illegal IP to judge and mark if ($rewrite = true) {# # match illegal IP, jump to main's web page rewrite (. +) / main.html } # match tag to redirect site location = / main.html {# # exactly match root / usr/share/nginx/html; # # site path} location / {root / usr/share/nginx/html; index index.html index.htm } 2, create illegal IP site and main web page [root@localhost conf.d] # cd / usr/share/nginx/html/ # # switch to site [root@localhost html] # vim main.html # # Edit illegal IP access web content this is test web [root@localhost html] # systemctl restart nginx # # restart Nginx service 3, visit the web page
Application scenario 3Mui-based on the old, the new domain name is redirected and the directory is added. All the posts under the domain name http://bbs.accp.com are redirected to http://www.accp.com/bbs and the parameters remain unchanged after the domain name jump. Modify the Nginx default configuration file [root@localhost ~] # cd / etc/nginx/conf.d/ [root@localhost conf.d] # vim default.conf # # modify the default configuration file server {listen 80 Server_name bbs.accp.com; # # modify service name # charset koi8-r; access_log / var/log/nginx/www.accp.com-access.log main; location / post {# # match post directory rewrite (. +) http://www.accp.com/bbs$1 permanent with location # # permanent redirect} 2, modify dns's zone data configuration file (accp.com.zone) [root@localhost conf.d] # cd / var/named/ [root@localhost named] # vim accp.com.zone # # modify the zone data configuration file $TTL 1D @ IN SOA @ rname.invalid. (0; serial 1D; refresh 1H; retry 1W Expire 3H) Minimum NS @ A 127.0.0.1bbs IN A 192.168.13.144 [root@localhost named] # systemctl restart named # # restart the resolution service [root@localhost named] # systemctl restart nginx # # restart the Nginx service [root@localhost named] # echo "nameserver 192.168.13.144" > / etc/resolv.conf # # put the resolution server address in the local resolution configuration file 3 Test the web page
Application scenario 4Mel-access http://www.accp.com/100-(100|200)-100.html to http://www.accp.com page 1 based on parameter matching jump browser, modify Nginx default configuration file [root@localhost ~] # cd / etc/nginx/conf.d/ [root@localhost conf.d] # vim default.conf server {listen 80; server_name www.accp.com; # charset koi8-r Access_log / var/log/nginx/www.accp.com-access.log main; if ($request_uri ~ ^ / 100-(100 | 200)-(\ d +) .html $) {# # match regular beginning with 100-(100 | 200)-multiple integer html ending with rewrite (. *) http://www.accp.com permanent # # permanent redirect to home page} 2, modify dns zone data configuration file [root@localhost conf.d] # vim / var/named/accp.com.zone # # modify zone data configuration file www IN A 192.168.13.144 [root@localhost conf.d] # systemctl restart named # # restart resolution service [root@localhost conf.d] # systemctl restart nginx # # restart Nginx service 3, test web page
Application scenario 5 listen-based on all PHP files in the directory jump access http://www.accp.com/upload/1.php jump to home page 1, modify the Nginx default configuration file [root@localhost ~] # cd / etc/nginx/conf.d/ [root@localhost conf.d] # vim default.conf # # modify the default profile server {listen 80; server_name www.accp.com; # profile Access_log / var/log/nginx/www.accp.com-access.log main; location ~ * / upload/.*\ .php ${# # matches rewrite (. +) http://www.accp.com permanent that ends with .php zero or more times after upload regardless of case # # Redirect to the home page} [root@localhost conf.d] # systemctl restart nginx # # restart Nginx service 2 and test the web page
Application scenario 6 url-A specific page is redirected to the home page 1 based on the most common url requests, and modify the Nginx default configuration file [root@localhost ~] # cd / etc/nginx/conf.d/ [root@localhost conf.d] # vim default.conf # # modify the Nginx default profile server {listen 80; server_name www.accp.com; # profile Access_log / var/log/nginx/www.accp.com-access.log main; location ~ * ^ / abc/123.html {# # match a specific web page rewrite (. +) http://www.accp.com permanent; # # Jump to the home page} [root@localhost conf.d] # systemctl restart nginx # # restart Nginx service 2 to test the web page
Thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.