Nginx installation and configuration load (ubuntu12.04)

After [previous article] (http://www.the5fire.com/python-supervisor-django-demo.html) talked about using supervisor to manage the process, it is natural to talk about using nginx to manage the ports monitored by the former startup program.

The first is to install nginx, the environment is still ubuntu12.04 (64-bit), through the following command:

sudo apt-get install nginx

After the installation is complete, it is started. At present, I know there are two ways to start under ubuntu:

sudo /etc/init.d/nginx start       #Through init.The startup file under d starts.
sudo service nginx start	#Start via ubuntu's service manager

Enter http://localhost in the browser and see if the "Welcome to nginx!" page appears. If not, continue to read the configuration first.

The last article talked about using supervisor to start two django processes, listening on ports 8000 and 8001 respectively, then how to make nginx forward access to these two ports, this must be done through the configuration file.

In my system, the nginx configuration file is under /etc/nginx.

Open the nginx.conf file and configure as follows:

# user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
 use epoll;
	worker_connections 768;
	# multi_accept on;}

http {
 include mime.types;
 default_type application/octet-stream;

 keepalive_timeout 120;

 tcp_nodelay on;

 upstream localhost {
  server 127.0.0.1:8000;
  server 127.0.0.1:8001;}

 server {
  listen 80;

  server_name localhost;

  location /{
   proxy_pass http://localhost;
   proxy_set_header Host $host;
   proxy_set_header X-Real_IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}}

This is ok, restart your nginx: sudo service nginx restart.

Then you can directly visit http://127.0.0.1 to access the django program that you started with supervisor, and load it on two ports. If you are interested, you can refer to my previous article "The Use of Web Stress Test ab Test" for down-stress test to see if it works.

Recommended Posts

Nginx installation and configuration load (ubuntu12.04)
Ubuntu PostgreSQL installation and configuration
Ubuntu 19.1 installation and configuration Chinese environment
Configuration and beautification after Ubuntu installation (1)
Ubuntu configuration source and installation software
Installation and deployment of Nginx in Ubuntu
Ubuntu install PHP and PHP Nginx configuration method
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
OpenMPI-Ubuntu installation and configuration
Debian and Ubuntu installation source configuration file description
Virtual machine installation and configuration ubuntu shared folder_
Kaldi installation and configuration graphic tutorials under Ubuntu
Basic configuration and common software installation after ubuntu 18.04 installation
Installation, configuration and uninstallation of GitLab in Ubuntu19.1
Centos mysql installation and configuration
Centos7 installation and configuration prometheus
CentOS 7 installation and configuration PPTP
CentOS installation and configuration cmake
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
Ubuntu16.04 install SVN and configuration
Ubuntu16.04 mirror complete installation and configuration tutorial under VMware
Ubuntu12 step-by-step installation and configuration (system, FTP, TELNET.. settings)
Common exceptions and solutions for Ubuntu system installation and configuration
Centos7 installation and configuration of Jenkins
Ubuntu environment variables and ADB configuration
Centos7 hadoop cluster installation and configuration
Ubuntu16.04 configuration OpenCV3.4.2 and basic use
Redis installation under ubuntu and windows
CentOS 7 Tomcat service installation and configuration
Ubuntu18.04 installation Anaconda3 and VSCode guide
Centos7 mysql database installation and configuration
Detailed explanation of quick installation and configuration of Subversion (SVN) under Ubuntu
CentOS 7 system installation and configuration graphic tutorial
ubuntu Docker installation and deployment of Rancher
Ubuntu installation and deployment Redash operation notes (2020.08)
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
Installation and configuration of redis under centos7
Installation and uninstallation of CUDA under Ubuntu 16.04
Ubuntu18.04 Server version installation and use (graphic)
Centos7 hive stand-alone mode installation and configuration
Deploy python3 and nginx projects on ubuntu18.04
Ubuntu 14.04 16.04 Linux nvidia driver download and installation
ubuntu 18.04 early configuration
UBUNTU 16.04 installation diary
ubuntu 1804 installation details
Ubuntu nfs configuration
Ubuntu system installation
Ubuntu20.04 configuration notes
Ubuntu installation record
Ubuntu 14.04 configuration record
ubuntu 18.04 installation (UEFI+GBT)
ubuntu installation error
CentOS 6.5 system installation and configuration graphic tutorial (detailed graphic)
Installation of pulseaudio and API usage under Ubuntu 12.04
The basic configuration and interface beautification of Ubuntu
CentOS 7 installation and configuration graphic tutorials under VMware10
Centos7 installation of PHP and Nginx tutorial detailed
Installation and configuration of rsync server under CentOS 6.5
Installation and configuration of CentOS 7 in VMware Workstation
Technical corner | Windows 10/7 and Ubuntu 18.04 dual system installation