学会配置nginx
一、作为一名开发人员,大家可能经常会用到服务器,但是一般线上的服务器可能都是公司公用的,而且线上的服务器一般也不是能随随便便给个人用的,所以部署本地服务器看来是一遍必不可少的事情和能力呀,所以,nginx腾空而出,它可以在任何一款vim终端配置部署,只要你能配置的好,它就是一款很不错的本地服务器,对你的开发有不小的帮助;
二、好了,废话不多说,接下来我给大家贴一个自己以往配置过的nginx配置:
##运行用户
#user nobody;
#启动进程,通常设置程和cpu的数量相等
worker_processes 1;
#全局错误日志及PID文件
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
##工作模式及连接数上限
events {
####epoll是多路复用IO(I/O Multiplexing)中的一种方式
#use epoll
###单个后台worker process 进程的最大并发链接数
worker_connections 1024;
}
http {
###设定mime类型,类型由mime.type文件定义
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指令指定nginx是否调用sendfile函数(zero copy方式)来输出文件,
##对于普通应用,必须设为 on,
#如果用来进行下载等应用磁盘IO重负载应用,可设置为 off,
#以平衡磁盘与网络I/O处理速度,降低系统的uptime.
sendfile on;
#tcp_nopush on;
#连接超时时间
#keepalive_timeout 0;
keepalive_timeout 65;
#开启gzip压缩
#gzip on;
#设定虚拟主机配置
server {
#侦听80端口
listen 8080;
#定义使用 localhost访问
server_name localhost;
#charset koi8-r;
#设定本虚拟主机的访问日志
#access_log logs/host.access.log main;
#location / {
#定义服务器的默认网站根目录位置
# root html;
# index index.html index.htm;
#}
location /rbac/ {
proxy_pass http://b1.rbac.wormpex.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
}
location /home/ {
proxy_pass http://0.0.0.0:8004;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
}
location /ticket/ {
proxy_pass http://0.0.0.0:8002/;
#####设置被代理服务器的端口或套接字,以及URL
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
####以上三行,目的是将代理服务器收到的用户的信息传到真实服务器上
client_max_body_size 10m;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# location / {
# root /usr/share/nginx/html;
# index index.html;
# }
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# #include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
include servers/*;
#include vhost/*.conf;
}
好了,这是自己实习期间部署的第一个nginx配置,大家可以根据自己的项目,作相应的改动;
学会配置nginx的更多相关文章
- [亲测]七步学会ASP.NET Core 2.0怎么发布/部署到Ubuntu Linux服务器并配置Nginx反向代理实现域名访问
前言 ASP.NET Core 2.0 怎么发布到Ubuntu服务器?又如何在服务器上配置使用ASP.NET Core网站绑定到指定的域名,让外网用户可以访问呢? 步骤 第1步:准备工作 一台Liun ...
- 分布式文件系统 - FastDFS 配置 Nginx 模块及上传测试
也不说废话,直接干 上一篇 分布式文件系统 - FastDFS 在 CentOS 下配置安装部署 中安装了 FastDFS 后,并配置启动了 Tracker 和 Storage 服务,已经可以上传文件 ...
- 如何正确配置Nginx+PHP
对很多人而言,配置Nginx+PHP无外乎就是搜索一篇教程,然后拷贝粘贴.听上去似乎也没什么问题,可惜实际上网络上很多资料本身年久失修,漏洞百出,如果大家不求甚解,一味的拷贝粘贴,早晚有一天会为此付出 ...
- [原创]Centos7 从零配置Nginx+PHP+MySql
序言 这次玩次狠得.除了编译器使用yum安装,其他全部手动编译.哼~ 看似就Nginx.PHP.MySql三个东东,但是它们太尼玛依赖别人了. 没办法,想用它们就得老老实实给它们提供想要的东西. 首先 ...
- 在ubuntu上面配置nginx实现反向代理和负载均衡
上一篇文章(http://www.cnblogs.com/chenxizhang/p/4684260.html),我做了一个实验,就是利用Visual Studio,基于Nancy框架,开发了一个自托 ...
- windows7配置Nginx+php+mysql教程
windows7配置Nginx+php+mysql教程 最近在学习php,想把自己的学习经历记录下来,并写一些经验,仅供参考交流.此文适合那些刚刚接触php,想要学习并想要自己搭建Nginx+php+ ...
- deepin 15.3 安装配置nginx
1.安装nginx sudo apt-get install nginx 2.配置nginx sudo gedit /etc/nginx/sites-enabled/default 找到:index ...
- 配置nginx+php
一般这样配置 此时很多教程会教大家这样配置Nginx+PHP: server { listen 80; server_name foo.com; root /path; location / { in ...
- CentOS6.5 简单配置Nginx + tomcat
1.配置nginx.conf vi /usr/local/nginx/conf/nginx.conf --这是你的安装目录 注:红框地方为任意位置,server在配置文件中已存在 我使用的是两个tom ...
随机推荐
- JAVA面向对象的三大特性 封装
将类的某些信息隐藏在类内部,不允许外部程序直接访问,而是通过该类提供的方法来实现对隐藏信息的操作和访问. 优点: 1只能通过规定的方法访问数据. 2隐藏类的实例细节,方便修改和实现. public c ...
- Erlang/OTP设计原则(文档翻译)
http://erlang.org/doc/design_principles/des_princ.html 图和代码皆源自以上链接中Erlang官方文档,翻译时的版本为20.1. 这个设计原则,其实 ...
- [Haskell] 为什么列表操作++很昂贵?
博主是haskell新手.学习haskll的时候遇到了一些问题,在寻求答案的过程中产生了一些思考,可能理解存在偏差,希望各位不吝赐教. 提出问题 <Learn you a haskell for ...
- 使用mysql悲观锁解决并发问题
最近学习了一下数据库的悲观锁和乐观锁,根据自己的理解和网上参考资料总结如下: 悲观锁介绍(百科): 悲观锁,正如其名,它指的是对数据被外界(包括本系统当前的其他事务,以及来自外部系统的事务处理)修改持 ...
- [hdu5632][BC#73 1002]Rikka with Array
点开BC发现今晚没比赛..然后似乎上一场有数位DP?...(幸好我没去 一开始被BCDcode那题的思路带歪了..后来发现得把n转成二进制才能搞TAT 题目大概是要求一种类似逆序对的鬼东西: 有一个长 ...
- Convex(扫描线降维)
Convex Time Limit: 10000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- HDU 5538 House Building(模拟——思维)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5538 Problem Description Have you ever played the vi ...
- Hive HQL学习
HQL学习 1.hive的数据类型 2.hive_DDL 2.1创建.删除.修改.使用数据库 Default数据库,默认的,优先级相对于其他数据库是最高的 2.2重点:创建表_内部表_ ...
- python通过scapy模块进行arp断网攻击
前言: 想实现像arpsoof一样的工具 arp断网攻击原理: 通过伪造IP地址与MAC地址实现ARP欺骗,在网络发送大量ARP通信量.攻击者 只要持续不断发送arp包就能造成中间人攻击或者断网攻击. ...
- input标签元素,value属性取值问题,赋值
验证val:<input type="text" id="id" name="name" value="空值"&g ...