Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Analysis of nginx Server configuration example under ubuntu

Shulou Source: shulou.com Published: 2022-05-31 12:27:34 09月23日 Update

This article mainly introduces "nginx server configuration case analysis under ubuntu". In daily operation, I believe that many people have doubts about nginx server configuration case analysis under ubuntu. Xiaobian consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful to answer the doubts of "nginx server configuration case analysis under ubuntu". Next, please follow the editor to study!

Detailed explanation of nginx server configuration under ubuntu

Installation of 1.nginx server

Sudo apt-get install nginx

Startup of 2.nginx server

Sudo / etc/init.d/nginx start

3. Multiple domain names correspond to different background servers

Delete the default configuration file in the / etc/nginx/sites-enabled/ directory

The configuration file for the new domain name

Like test.youlunshidai.com.

# through upstream nodejs__upstream, you can configure multiple nodejs nodes to do load balancer upstream nodejs__upstream__test__youlunshidai {server 127.0.0.1 upstream nodejs__upstream__test__youlunshidai 8089; # server address and port number # server 127.0.1 upstream nodejs__upstream__test__youlunshidai 8088; # load balancer server address and port number keepalive 64; # set the time to live. If not set, a large number of timewait} server {listen 80; server_name test.youlunshidai.com; access_log / var/log/nginx/test_youlunshidai.log; # nginx log files location / {proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; proxy_set_header x-nginx-proxy true; proxy_set_header connection "; proxy_http_version 1.1 may be generated. Proxy_pass http://nodejs__upstream__test__youlunshidai; # reverse proxy forwarding http://nodejs__upstream;}}

If there are other domain names and background servers, you can continue to create the corresponding domain name profile in the directory.

At this point, the study of "nginx server configuration instance analysis under ubuntu" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Server service configuration instance instance analysis analysis file learning domain name balance slogan background address more directory help different practical next multiple Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Xiaomi MySQL Shulou Tech Info Apple