In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how nginx configures secondary domain names". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to configure secondary domain names in nginx"!
my vps has three services, namely:
Wordpress built blog service, running on port 8000, access http://fangyuanxiaozhan.com:8000
Git service built by gogs, running on port 10080, access http://fangyuanxiaozhan.com:10080
nextcloud built network disk service, running on port 8080, access http://fangyuanxiaozhan.com:10080
My needs:
1. To access the blog service, type http://fangyuanxiaozhan.com directly
To access git services, type http://git.fangyuanxiaozhan.com directly
When accessing the web disk service, enter http://cloud.fangyuanxiaozhan.com directly
implemented method
1, to host the domain name website, add dns resolution, my domain name fangyuanxiaozhan.com hosted in Alibaba Cloud, my practice is to log in https://dns.console.aliyun.com/#/dns/domainlist, add secondary records
2, I use centos7, the default location of nginx configuration file is/etc/nginx/nginx.conf , interesting is that/etc/nginx/nginx.conf introduced configuration folder/etc/nginx/conf.d , that is, we can comment some default configuration in/etc/nginx/nginx.conf, directly configure multiple independent configuration files in the folder/etc/nginx/conf.d.
The requested URL/etc/nginx/nginx.conf was not found on this server.
# for more information on configuration, see:# * official english documentation: http://nginx.org/en/docs/# * official russian documentation: http://nginx.org/ru/docs/user nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;# load dynamic modules. see /usr/share/nginx/readme.dynamic.include /usr/share/nginx/modules/*.conf;events { worker_connections 1024;}http { 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 /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf;}
Note that the last line of the above configuration file, including/etc/nginx/conf.d/*.conf; ensures that all configuration files ending in.conf under/etc/nginx/conf.d/will be imported and validated by the main configuration file nginx.conf
You need to create three new files under/etc/nginx/conf.d/
blog.conf (port 8000 mapped to port 80, no second-level domain names)
server { listen 80; server_name fangyuanxiaozhan.com; location / { proxy_set_header x-real-ip $remote_addr; proxy_set_header host $http_host; proxy_pass http://0.0.0.0:8000; }}
blog.conf implements fangyuanxiaozhan.com:8000 mapping to fangyuanxiaozhan.com
git.conf (port 10080 mapped to port 80, using the second-level domain name git )
server { listen 80; server_name git.fangyuanxiaozhan.com; location / { proxy_set_header x-real-ip $remote_addr; proxy_set_header host $http_host; proxy_pass http://0.0.0.0:10080; }}
git.conf implements fangyuanxiaozhan.com:10080 mapped to git.fangyuanxiaozhan.com
nc.conf (mapping port 10080 to port 80, using the second-level domain name cloud )
server { listen 80; server_name cloud.fangyuanxiaozhan.com; location / { proxy_set_header x-real-ip $remote_addr; proxy_set_header host $http_host; proxy_pass http://0.0.0.0:8080; }}
git.conf implements fangyuanxiaozhan.com:8080 mapping to cloud.fangyuanxiaozhan.com
Restart nginx to take effect
Close nginx
sudo $(which nginx) -s stop
Open nginx
sudo $(which nginx)
effect display
At this point, I believe that everyone has a deeper understanding of "how nginx configures secondary domain names", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
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.