In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "distributed service Nginx building and deployment configuration method", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "distributed service Nginx building and deployment configuration method" bar!
one。 Deployment and configuration of Nginx
1. Test the version of the system: centOS7
CentOS 7, install Nginx using yum
Install the Nginx source
Rpm-ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
After installing the rpm, we can see a file called nginx.repo in the / etc/yum.repos.d/ directory.
Install Nginx
After installing the Nginx source, you can officially install Nginx.
Yum install-y nginx
The following is the default path for Nginx:
(1) Nginx configuration path: / etc/nginx/
(2) PID directory: / var/run/nginx.pid
(3) error log: / var/log/nginx/error.log
(4) access log: / var/log/nginx/access.log
(5) default site directory: / usr/share/nginx/html
In fact, as long as you know the Nginx configuration path, other paths can be queried in / etc/nginx/nginx.conf and / etc/nginx/conf.d/default.conf
Common command
(1) start:
Nginx
(2) Test whether the Nginx configuration is correct:
Nginx-t
(3) graceful restart:
Nginx-s reload
(4) check the process number of nginx:
Ps-ef | grep nginx
(5) nginx service stops
Nginx-s stopkill-9 pid
The edited nginx.conf configuration file is as follows
User nginx
Worker_processes 1
Error_log / var/log/nginx/error.log warn
Pid / var/run/nginx.pid
Events {
Worker_connections 1024
}
Http {
Include / etc/nginx/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 $request_time $upstream_response_time'
Log_format log_wisecloud'{"project": "New Cloud",'
'"@ timestamp": "$time_local",'
'"remote_addr": "$remote_addr",'
'"request_host": "$http_host",'
'"request_api": "$uri",'
'"request_uri": "$request_uri",'
'"request_method": "$request_method",'
'"status": "$status",'
'"body_bytes_sent": "$body_bytes_sent",'
'"request_time": "$request_time",'
'"upstream_response_time": "$upstream_response_time",'
'"upstream_addr": "$upstream_addr",'
'"http_x_forwarded_for": "$http_x_forwarded_for",'
'"http_referrer": "$http_referer",'
'"http_user_agent": "$http_user_agent"}'
Access_log / var/log/nginx/access.log main
Sendfile on
# tcp_nopush on
Keepalive_timeout 65
Client_max_body_size 2048m
Client_body_buffer_size 1024m
Client_header_timeout 4800s
Client_body_timeout 4800s
Client_header_buffer_size 1280m
Large_client_header_buffers 4 1280m
Fastcgi_connect_timeout 3000s
Fastcgi_send_timeout 3000s
Fastcgi_read_timeout 3000s
Fastcgi_buffer_size 1280k
Fastcgi_buffers 2 2560k
Fastcgi_busy_buffers_size 2560k
Fastcgi_temp_file_write_size 2560k
Fastcgi_ignore_client_abort on
Proxy_connect_timeout 3000
Proxy_send_timeout 3000
Proxy_read_timeout 3000
Proxy_ignore_client_abort on
Gzip on
Gzip_http_version 1.0
Gzip_min_length 1k
Gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/json application/x-www-form-urlencoded
Include / etc/nginx/conf.d/*.conf
}
# # Module configuration #
Test-80.conf
Server {
Listen 80
Server_name xxxx.yyy.com
Access_log / var/log/nginx/cloud-cn.log log_cloud
Ssl_certificate / etc/nginx/ssl/cloud-cn.coud.com.pem
Ssl_certificate_key / etc/nginx/ssl/cloud-cn.cloud.com.key
Ssl_protocols TLSv1 TLSv1.1 TLSv1.2
Ssl_ciphers AESGCM all rig "DHV" export "RC4"HIGH"MEDIUM"LOW"aNULLL"enull"
Ssl_session_timeout 5m
Ssl_prefer_server_ciphers on
# location @ router {
# rewrite ^. * $/ index.html last
#}
Location / api/ {
Proxy_pass http://192.168.1.13:8083/;
Proxy_set_header Host $host:$server_port
Proxy_set_header X-Real-IP $remote_addr
Proxy_set_header X-Real-PORT $remote_port
Proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
Proxy_connect_timeout 600s
Proxy_send_timeout 600s
Proxy_read_timeout 600s
Fastcgi_connect_timeout 600s
Fastcgi_send_timeout 600s
Fastcgi_read_timeout 600s
}
Location / config/ {
Proxy_pass http://localhost:8082/;
Proxy_set_header Host $host:$server_port
Proxy_set_header X-Real-IP $remote_addr
Proxy_set_header X-Real-PORT $remote_port
Proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
}
Location / check.html {
Alias / etc/nginx/health/check.html
}
Location / {
Alias / home/html/dist/
Try_files $uri $uri/ / index.html
Index index.htm index.html index.php
}
}
# https 443 module configuration #
Server {
Listen 80
Server_name xxx.yyy.com
Access_log / var/log/nginx/name-cn.log log_name
Ssl_certificate / etc/nginx/ssl/test-cn.testeasy.com.pem
Ssl_certificate_key / etc/nginx/ssl/test.test.com.key
Server {
Listen 80
Server_name xxx.yyy.com
Access_log / var/log/nginx/test-cn.log log_wisecloud
Ssl_certificate / etc/nginx/ssl/test-cn.test.com.pem
Ssl_certificate_key / etc/nginx/ssl/test.test.com.key
Ssl_protocols TLSv1 TLSv1.1 TLSv1.2
Ssl_ciphers AESGCM all rig "DHV" export "RC4"HIGH"MEDIUM"LOW"aNULLL"enull"
Ssl_session_timeout 5m
Ssl_prefer_server_ciphers on
# location @ router {
# rewrite ^. * $/ index.html last
#}
Location / api/ {
Proxy_pass http://192.168.1.13:8083/;
Proxy_set_header Host $host:$server_port
Proxy_set_header X-Real-IP $remote_addr
Proxy_set_header X-Real-PORT $remote_port
Proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
Proxy_connect_timeout 600s
Proxy_send_timeout 600s
Proxy_read_timeout 600s
Fastcgi_connect_timeout 600s
Fastcgi_send_timeout 600s
Fastcgi_read_timeout 600s
}
Location / config/ {
Proxy_pass http://localhost:8082/;
Proxy_set_header Host $host:$server_port
Proxy_set_header X-Real-IP $remote_addr
Proxy_set_header X-Real-PORT $remote_port
Proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
}
Location / check.html {
Alias / etc/nginx/health/check.html
}
Location / {
Alias / home/html/dist/
Try_files $uri $uri/ / index.html
Index index.htm index.html index.php
}
}
Thank you for your reading. the above is the content of "distributed service Nginx building and deployment configuration method". After the study of this article, I believe you have a deeper understanding of the problem of distributed service Nginx building and deployment configuration method, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.