启动
直接点击Nginx目录下的nginx.exe 或者 cmd运行start nginx
关闭
nginx -s stop 或者 nginx -s quit
stop表示立即停止nginx,不保存相关信息
quit表示正常退出nginx,并保存相关信息
重启(因为改变了配置,需要重启)
引入一个配置 include apps/test.conf;
#user nobody; | |
worker_processes 4; | |
worker_cpu_affinity 0001 0010 0100 1000; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include 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"'; | |
#access_log logs/access.log main; | |
sendfile on; | |
#tcp_nopush on; | |
#keepalive_timeout 0; | |
keepalive_timeout 65; | |
gzip on; | |
server { | |
listen 7080; | |
server_name localhost; | |
proxy_buffer_size 128k; | |
proxy_buffers 4 256k; | |
proxy_busy_buffers_size 256k; | |
default_type 'text/html'; | |
charset utf-8; | |
location ^~ / { | |
root html; | |
index index.html index.htm; | |
proxy_pass http://localhost:8080; | |
proxy_set_header X-Real-IP $remote_addr; | |
} | |
location ^~ /jade2/ { | |
root html; | |
index index.html index.htm; | |
proxy_pass http://10.181.0.128:8081; | |
proxy_set_header X-Real-IP $remote_addr; | |
expires 30d; | |
} | |
location ^~ /app/ { | |
root "E:/_staticweb/"; | |
} | |
} | |
} |
#映射jade2开头的url到指定web服务器(比如tomcat),url: http://localhost:7080/jade2/index.jsp | |
location ^~ /jade2/ { | |
root html; | |
index index.html index.htm; | |
proxy_pass http://10.181.0.128:8081; | |
proxy_set_header X-Real-IP $remote_addr; | |
expires 30d;#客户端缓存30天 | |
} | |
#映射所有未配置的url到8080端口 | |
location ^~ / { | |
root html; | |
index index.html index.htm; | |
proxy_pass http://localhost:8080; | |
proxy_set_header X-Real-IP $remote_addr; | |
} |
#映射E:\_staticweb\app下的所有文件,例如当用户访问http://localhost:7080/app/wmstopo.html时,将访问E:\_staticweb\app\wmstopo.html | |
location ^~ /app/ { | |
root "E:/_staticweb/"; | |
} |
#配置一组名为gs的集群 | |
upstream gs{ | |
least_conn; | |
server 10.111.58.120:8282; | |
server 10.111.58.122:8282; | |
server 10.111.4.200:7001; | |
} | |
server { | |
listen 7080; | |
server_name localhost; | |
proxy_buffer_size 128k; | |
proxy_buffers 4 256k; | |
proxy_busy_buffers_size 256k; | |
#所有geoserver开头的请求转发到gs集群 | |
location ^~ /geoserver/ { | |
proxy_pass http://gs; | |
} | |
} |