栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

配置nginx

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

配置nginx

额,水文章
nginx作为常用的负载均衡,反向代理等web服务早已与tomcat,apache齐名。
nginx常用的命令

nginx  -s stop 退出
nginx -s quit 强制退出
nginx -s reload 重启

nginx -v 版本
nginx -h 查help

主要如何配置本地的是访问conf包里的http{}
这是我的nginx目录

.
├── cert
├── client_body_temp [error opening dir]
├── conf
│   ├── fastcgi.conf
│   ├── fastcgi.conf.default
│   ├── fastcgi_params
│   ├── fastcgi_params.default
│   ├── koi-utf
│   ├── koi-win
│   ├── mime.types
│   ├── mime.types.default
│   ├── nginx.conf
│   ├── nginx.conf.default
│   ├── scgi_params
│   ├── scgi_params.default
│   ├── uwsgi_params
│   ├── uwsgi_params.default
│   └── win-utf
├── fastcgi_temp [error opening dir]
├── html
│   ├── 50x.html
│   └── index.html
├── logs
│   ├── access.log
│   ├── error.log
│   └── nginx.pid
├── proxy_temp [error opening dir]
├── sbin
│   └── nginx
├── scgi_temp [error opening dir]
└── uwsgi_temp [error opening dir]

10 directories, 21 files

default的呢是默认的最先访问

首先开始使用ifconfig知道自己的ip

(base) ni@nideMacBook-Pro ~ % ifconfig
lo0: flags=8049 mtu 16384
	options=1203
	inet 127.0.0.1 netmask 0xff000000
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
	nd6 options=201
gif0: flags=8010 mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863 mtu 1500
	options=400
	ether a0:99:9b:1b:69:a1
	inet6 fe80::cf5:91b0:dcdf:6daf%en0 prefixlen 64 secured scopeid 0x4
	inet 192.168.1.103 netmask 0xffffff00 broadcast 192.168.1.255
	nd6 options=201
	media: autoselect
	status: active
en1: flags=8963 mtu 1500
	options=460
	ether 82:13:09:1a:c6:40
	media: autoselect 
	status: inactive
en2: flags=8963 mtu 1500
	options=460
	ether 82:13:09:1a:c6:41
	media: autoselect 
	status: inactive
bridge0: flags=8863 mtu 1500
	options=63
	ether 82:13:09:1a:c6:40
	Configuration:
		id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
		maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
		root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
		ipfilter disabled flags 0x0
	member: en1 flags=3
	        ifmaxaddr 0 port 5 priority 0 path cost 0
	member: en2 flags=3
	        ifmaxaddr 0 port 6 priority 0 path cost 0
	nd6 options=201
	media: 
	status: inactive
p2p0: flags=8843 mtu 2304
	options=400
	ether 02:99:9b:1b:69:a1
	media: autoselect
	status: inactive
awdl0: flags=8943 mtu 1484
	options=400
	ether 4e:db:7b:4a:55:90
	inet6 fe80::4cdb:7bff:fe4a:5590%awdl0 prefixlen 64 scopeid 0x9
	nd6 options=201
	media: autoselect
	status: active
llw0: flags=8863 mtu 1500
	options=400
	ether 4e:db:7b:4a:55:90
	inet6 fe80::4cdb:7bff:fe4a:5590%llw0 prefixlen 64 scopeid 0xa
	nd6 options=201
	media: autoselect
	status: active
utun0: flags=8051 mtu 1380
	inet6 fe80::f148:88a3:4ebf:2786%utun0 prefixlen 64 scopeid 0xb
	nd6 options=201
utun1: flags=8051 mtu 2000
	inet6 fe80::56b8:90bc:8c4a:89e8%utun1 prefixlen 64 scopeid 0xc
	nd6 options=201

自己的就是这个192.168.1.103
在写入到nginx里面的server中

 35     server {
 36         listen       81;
 37         server_name  192.168.1.103;
 38
 39         #charset koi8-r;
 40
 41         #access_log  logs/host.access.log  main;
 42
 43         location / {
 44             root   html;
 45             index  index.html index.htm;
 46             proxy_pass   http://192.168.1.103;
 47         }

至于为什么不能写https是因为没有绑定ssl协议

开始试一试就ok了。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/613819.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号