一、作为一名开发人员,大家可能经常会用到服务器,但是一般线上的服务器可能都是公司公用的,而且线上的服务器一般也不是能随随便便给个人用的,所以部署本地服务器看来是一遍必不可少的事情和能力呀,所以,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的更多相关文章

  1. [亲测]七步学会ASP.NET Core 2.0怎么发布/部署到Ubuntu Linux服务器并配置Nginx反向代理实现域名访问

    前言 ASP.NET Core 2.0 怎么发布到Ubuntu服务器?又如何在服务器上配置使用ASP.NET Core网站绑定到指定的域名,让外网用户可以访问呢? 步骤 第1步:准备工作 一台Liun ...

  2. 分布式文件系统 - FastDFS 配置 Nginx 模块及上传测试

    也不说废话,直接干 上一篇 分布式文件系统 - FastDFS 在 CentOS 下配置安装部署 中安装了 FastDFS 后,并配置启动了 Tracker 和 Storage 服务,已经可以上传文件 ...

  3. 如何正确配置Nginx+PHP

    对很多人而言,配置Nginx+PHP无外乎就是搜索一篇教程,然后拷贝粘贴.听上去似乎也没什么问题,可惜实际上网络上很多资料本身年久失修,漏洞百出,如果大家不求甚解,一味的拷贝粘贴,早晚有一天会为此付出 ...

  4. [原创]Centos7 从零配置Nginx+PHP+MySql

    序言 这次玩次狠得.除了编译器使用yum安装,其他全部手动编译.哼~ 看似就Nginx.PHP.MySql三个东东,但是它们太尼玛依赖别人了. 没办法,想用它们就得老老实实给它们提供想要的东西. 首先 ...

  5. 在ubuntu上面配置nginx实现反向代理和负载均衡

    上一篇文章(http://www.cnblogs.com/chenxizhang/p/4684260.html),我做了一个实验,就是利用Visual Studio,基于Nancy框架,开发了一个自托 ...

  6. windows7配置Nginx+php+mysql教程

    windows7配置Nginx+php+mysql教程 最近在学习php,想把自己的学习经历记录下来,并写一些经验,仅供参考交流.此文适合那些刚刚接触php,想要学习并想要自己搭建Nginx+php+ ...

  7. deepin 15.3 安装配置nginx

    1.安装nginx sudo apt-get install nginx 2.配置nginx sudo gedit /etc/nginx/sites-enabled/default 找到:index ...

  8. 配置nginx+php

    一般这样配置 此时很多教程会教大家这样配置Nginx+PHP: server { listen 80; server_name foo.com; root /path; location / { in ...

  9. CentOS6.5 简单配置Nginx + tomcat

    1.配置nginx.conf vi /usr/local/nginx/conf/nginx.conf --这是你的安装目录 注:红框地方为任意位置,server在配置文件中已存在 我使用的是两个tom ...

随机推荐

  1. C#设计模式之总结篇

    一.引言     C#版本的23种设计模式已经写完了,现在也到了一个该总结的时候了.说起设计模式,我的话就比较多了.刚开始写代码的时候,有需求就写代码来解决需求,如果有新的需求,或者需求变了,我就想当 ...

  2. Send Email in .NET Core 2.0

    在.NET Core 1.0 中,SMTP Client代码并没有被移植,直到.NET Core 2.0的发布.使用下面的代码: static void Main(string[] args) { S ...

  3. WPF 依赖属性源码 洞察微软如何实现DependencyProperty

    依赖属性DependencyProperty是wpf最重要的一个类,理解该类如何实现对学习wpf帮助很大! 终于找到了该类的源码!仔细阅读源码,看看微软如何玩的花招! File: Base\Syste ...

  4. 使用jemeter手工编写注册、登陆脚本 运用 fiddler (二)

    接着上一篇讲 我们需要添加关联来获取我们想要的动态值 如果做过自动化测试的人都知道   不管是注册或者登陆是时候都会有一个 类似于动态码的一个东西  只有这个东西验证成功 我们才能注册 或者 登陆 那 ...

  5. C++面向对象作业1

    #include <iostream> #include <stdlib.h> using namespace std; class Tdate { public: Tdate ...

  6. Codeforces Round #416(Div. 2)-811A.。。。 811B.。。。 811C.dp。。。不会

    CodeForces - 811A A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 meg ...

  7. A Bug's Life(种类并查集)(也是可以用dfs做)

    http://acm.hdu.edu.cn/showproblem.php?pid=1829   A Bug's Life Time Limit:5000MS     Memory Limit:327 ...

  8. NullPointerException org.apache.commons.digester.Digester.getXMLReader(Digester.java:1058)

    http://pwu-developer.blogspot.com/2010/01/nullpointerexception.html Maven is great build tool making ...

  9. 98、vue.js简单入门

    本篇导航: 介绍与安装 vue常用指令 一.介绍与安装 vue是一套构建用户界面的JAVASCRIPT框架.与其它大型框架不同的是,Vue 被设计为可以自底向上逐层应用.Vue 的核心库只关注视图层, ...

  10. php通过ini_set调用output_compression压缩网页

    网页压缩是一种网页优化技术,可以让网页体积缩小后再传输到客户端,从而减少数据传送量,提高速度.这种技术现在使用已经相当普遍,绝大多数网页都使用了这种技术. 网页压缩可以在服务器或空间里通过参数设置启用 ...