学会配置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 ...
随机推荐
- js实现黑客帝国文字下落效果
突然想到这个效果便想实现以下. 当然免不了要百度一下,于是查找到 http://www.cnblogs.com/myvin/p/4775152.html这篇文章, 效果可以查看博文中的给出的效果图.那 ...
- Python类的多态的例子
1 # -*- coding: utf-8 -*- 2 # 类的多态 3 4 # 定义Person父类 5 class Person(object): 6 def __init__(self, nam ...
- Jquery_基础(一) 常用方法与选择器
一.Jquery常用方法: $(function(){ //掌握$() 以及function(){} 结合 $("#a01").click(function(){ alert('h ...
- Java_web学习(一) jdk配置
1.下载好jdk1.8.0版本或以上版本 2.配置JAVA_HOME,CLASSPATH,PATH 其中JAVA_HOME必须的 2.1 JAVA_HOME=E:\java\jdk1.8.0_77 ...
- flask开发框架
# -*- coding: utf-8 -*- # import fcrm from fcrm import app if __name__ == '__main__': # fcrm.app.run ...
- 请求库-request使用
# -*- coding: utf-8 -*- import requests from urllib.parse import urlencode # python模仿百度搜索引擎 # keywor ...
- Linux ssh双向免密认证
一.实现原理 使用一种被称为"公私钥"认证的方式来进行ssh登录."公私钥"认证方式简单的解释是: 首先在客户端上创建一对公私钥(公钥文件:~/.ssh/id_ ...
- React入门实例教程
文章转自:阮一峰 现在最热门的前端框架,毫无疑问是 React . 上周,基于 React 的 React Native 发布,结果一天之内,就获得了 5000 颗星,受瞩目程度可见一斑. React ...
- ubuntu下查看-卸载软件(卸载.net core sdk的方法)
查看已安装的包:dpkg --list 查看正则匹配的包:dpkg --list 'dotnet-*' //查看以dotnet-开头的包 卸载匹配的包:sudo apt-get --purge rem ...
- 【Java学习笔记之二十七】Java8中传多个参数时的方法
java中传参数时,在类型后面跟"..."的使用: public static void main(String[] args){ testStringA ...