nginx实战操作(常用命令及配置)
1. nginx介绍
2. nginx常用命令
验证配置是否正确: nginx -t
查看Nginx的详细的版本号:nginx -V
查看Nginx的简洁版本号:nginx -v
启动Nginx:start nginx
快速停止或关闭Nginx:nginx -s stop
正常停止或关闭Nginx:nginx -s quit
配置文件修改重装载命令:nginx -s reload
3. nginx配置
3.1 配置代码
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#1 start
upstream linuxidc {
server localhost:7071;
server localhost:7072;
server localhost:7073;
}
server {
listen 7070;
server_name localhost;
location / {
# root C:/ngtest2;
# index index.html index.htm;
proxy_pass http://linuxidc;
}
}
# 1 end
#2 start
server {
listen 7071;
server_name localhost;
location / {
root C:/ngtest1;
# index index.html index.htm;
#proxy_pass https://tms;
#proxy_pass https://www.baidu.com/;
}
}
server {
listen 7072;
server_name localhost;
location / {
root C:/ngtest2;
# index index.html index.htm;
#proxy_pass https://tms;
}
}
server {
listen 7073;
server_name localhost;
location / {
root C:/ngtest3;
# index index.html index.htm;
#proxy_pass https://tms;
}
}
# 2 end
#3 start
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
# root C:\ngtest;
#index index.html index.htm;
#proxy_pass https://www.baidu.com/;
# }
location /baidu {
#root html;
#index index.html index.htm;
proxy_pass https://www.baidu.com/;
}
location /csdn {
#root html;
#index index.html index.htm;
proxy_pass https://www.csdn.net/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# 3 end
}
}
3.2 代码说明及效果图
3.2.1 不同端口代理不同应用
#2 start
server {
listen 7071;
server_name localhost;
location / {
root C:/ngtest1;
# index index.html index.htm;
#proxy_pass https://tms;
#proxy_pass https://www.baidu.com/;
}
}
server {
listen 7072;
server_name localhost;
location / {
root C:/ngtest2;
# index index.html index.htm;
#proxy_pass https://tms;
}
}
server {
listen 7073;
server_name localhost;
location / {
root C:/ngtest3;
# index index.html index.htm;
#proxy_pass https://tms;
}
}
# 2 end
3.2.2 效果图
3.2.3 同一端口号代理不同应用
#3 start
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
# root C:\ngtest;
#index index.html index.htm;
#proxy_pass https://www.baidu.com/;
# }
location /baidu {
#root html;
#index index.html index.htm;
proxy_pass https://www.baidu.com/;
}
location /csdn {
#root html;
#index index.html index.htm;
proxy_pass https://www.csdn.net/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# 3 end
3.2.4 效果图
3.2.5 负载均衡
默认采用的轮询方式
#1 start
upstream linuxidc {
server localhost:7071;
server localhost:7072;
server localhost:7073;
}
server {
listen 7070;
server_name localhost;
location / {
# root C:/ngtest2;
# index index.html index.htm;
proxy_pass http://linuxidc;
}
}
# 1 end
3.2.6 效果图
nginx实战操作(常用命令及配置)的更多相关文章
- window下nginx的常用命令
window nginx 启动 常用命令 2016-05-04 11:11 214人阅读 评论(0) 收藏 举报 分类: nginx(5) 版权声明:本文为博主原创文章,未经博主允许不得转载. 启动 ...
- Vim常用命令及配置方案
Vim常用命令及配置方案 几句话 很久之前就接触到vim,初学那阵觉得vim很酷炫,但确实对新手不是很友好.我也就简单看了下基本操作就上手了,但又不是长期在vim下工作,这就导致了每一次重新使用v ...
- WebSphere MQ常用命令及配置
WebSphere MQ常用命令及配置 (2012-06-23 23:09:16) 标签: mq命令 杂谈 分类: MQ [导读]WebSphere MQ常用命令及配置 一,队列管理命令 1,创建队列 ...
- nginx常用命令和配置
1.常用命令 查看版本号: ./nginx -v 启动nginx:在/usr/local/nginx/sbin 目录下执行 ./nginx 关闭nginx:在/usr/local/nginx ...
- linux下安装nginx以及常用命令指南
安装nginx之前,要先在服务器上安装nginx运行所需要的依赖包 目录选择:一般选择 "/usr/local/" 1.安装PCRE库 离线安装包:https://pan.baid ...
- ubuntu和centos 编译安装nginx及常用命令
转自http://www.cnblogs.com/piscesLoveCc/p/5794926.html 一. ubuntu安装 1. 安装依赖库 安装gcc g++的依赖库 ubuntu平台可以使用 ...
- Linux上安装Nginx及常用命令
一.Linux安装软件常用方法 1.rpm(或pkg)安装,类似于Windows安装程序,是预编译好的程序. 1)使用的是通用参数编译,配置参数不是最佳 2)可控制性不强,比如对程序特定组件的定制性安 ...
- nginx的常用命令
一.nginx的解压安装 #tar xzvf nginx-1.6.0.tar.gz #cd nginx-1.6.0 #./configure --prefix=/home/weixin/loca ...
- linux安装jdk tomcat nginx 以及常用命令
linux: 操作系统,应用服务器上 常用命令: cd 切换命令 cd / cd ~ cd ../../ cd xx ll 展示所有的文件 ll -h 友好的展示 mkdir 创建目录 mkdir 目 ...
随机推荐
- Win8 Metro(C#)数字图像处理--3.5图像形心计算
原文:Win8 Metro(C#)数字图像处理--3.5图像形心计算 /// <summary> /// Get the center of the object in an image. ...
- Android基础开发入门(一)
前言:我学了一年多的C#(从学编程算起,也没有两年,我现在大二下),中间也一直在学WP开发,虽然技术不咋地,很渣渣,但微软在Build大会上宣布的策略让我觉得有必要学习一下安卓开发了.关于微软的策略, ...
- 零元学Expression Blend 4 - Chapter 6 如何置入Photoshop档案以及入门动画设计
原文:零元学Expression Blend 4 - Chapter 6 如何置入Photoshop档案以及入门动画设计 本章将教大家如何把Photoshop档案置入Expression Blend ...
- UWP中String 转为Path Data
定义方法: Geometry PathMarkupToGeometry(string pathMarkup) { string xaml = "<Path " + " ...
- SQL Server中 SET 和 SELECT 赋值有什么区别?
SQL Server 中对已经定义的变量赋值的方式用两种,分别是 SET 和 SELECT.对于这两种方式的区别,SQL Server 联机丛书中已经有详细的说明,但很多时候我们并没有注意,其实这两种 ...
- Android Java调用Qt写的so库
有时候,我们反编译apk得到一个so库,如果直接使用这个so库的话,必须使用原来so库同样的package名字,才能用.这样人家反编译你的apk,就知道你侵犯了人家的版权.为了达到混淆的目的,我们可以 ...
- B/s发展情况真的可以用日新月异来形容
做c/s也做b/s.从发展情况看,B/s发展情况真的可以用日新月异来形容,但确实也有些绕着路走的框架,不如delphi层次结构清晰. 如果前端用过angularjs等类似框架,则已经相当接近c/s的水 ...
- 4月份本周超过 10 款最新免费 jQuery 插件
分享 <关于我> 分享 [中文纪录片]互联网时代 http://pan.baidu.com/s/1qWkJfcS 分享 <HTML开发MacOSAp ...
- 实现Qt日志功能并输出到文件(使用qInstallMsgHandler安装customMessageHandler)good
原文 http://www.cppblog.com/lauer3912/archive/2011/04/10/143870.html 一.基本分类:qDebug : 调试信息提示qWarning: 一 ...
- xe5 for android 地理定位GPS
先上源码,在解释. implementation uses androidapi.jni.JavaTypes, androidapi.jni.Location, FMX.helpers.android ...