Nginx配置文件示例
Nginx的配置文件示例:(仅供参考)
强烈建议先将默认的配置文件备份再进行操作!
请根据自己项目的实际路径来配置相关路径!
uwsgi配置文件请参考:uwsgi配置文件示例
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
# user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
server_name www.******.com;
charset utf-8;
rewrite ^(.*)$ https://www.******.com permanent;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
# 如果用到了ssl,就把下面这一段注释掉。否则的话需要解开注释,把后面监听443端口的都注释掉
# location /api{
# include uwsgi_params;
# uwsgi_pass 127.0.0.1:8001; # 转发到内部8001端口来处理,必须和uwsgi中的设置一致
# client_max_body_size 35m;
# }
#
# location / {
# root /home/www/blog_front;
# index index.html;
# }
#
# location /static {
# alias /home/blog/Blog/statics;
#
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
}
# 如果没有ssl证书可以不填写这个,或者全部注释掉
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
# server_name ******.com;
# rewrite ^(.*)$ https://www.******.com permanent;
# root /usr/share/nginx/html;
ssl on;
ssl_certificate "/etc/pki/nginx/server.crt"; # 这里根据自己的ssl证书的路径填写
ssl_certificate_key "/etc/pki/nginx/private/server.key"; # 这里根据自己的ssl证书的路径填写
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
# 这里的/api表示后端请求的地址为https://域名:端口/api/参数
location /api{
include uwsgi_params;
uwsgi_pass 127.0.0.1:8001; # 转发到内部8001端口来处理,必须和uwsgi中的设置一致
client_max_body_size 35m;
}
location / {
root /home/www/blog_front;
index index.html;
}
location /static {
alias /home/blog/Blog/statics;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
转载请注明出处!
Nginx配置文件示例的更多相关文章
- uwsgi配置文件示例
uwsgi配置文件参考 相关路径请根据自己项目的实际路径配置 在进行Nginx+uwsgi部署Django项目的时候,需要Nginx的配置中包含uwsgi的配置项,具体请查看另一篇:Nginx配置文件 ...
- NGINX配置文件优化示例
Nginx主配置文件 upstream.conf配置文件 # server nginx配置文件最好分开写,不要把所有的逻辑都放在一个文件里面,会看着很麻烦,,之前我的配置文件都放一起了,,导致现在维护 ...
- 一、Nginx配置文件详解
配置文件介绍 主要有两部分:分别是 main:主体部分 http{}:虚拟主机配置部分 配置指令主要以分号结尾:配置语法:directive value1 [value2 ....] 支持使用的变量 ...
- nginx配置文件中的location理解
关于一些对location认识的误区 1. location 的匹配顺序是"先匹配正则,再匹配普通". 矫正: location 的匹配顺序其实是"先匹配普通,再匹配正则 ...
- nginx配置文件详解(三)
nginx配置文件详细解析 nginx安装目录: /usr/local/nginx 配置文件: /usr/local/nginx/conf 目录下的 nginx.conf文件 nginx优化方法1 ...
- nginx入门示例(二)
nginx使用域名访问 (Tip) nginx目录解析 conf/nginx.conf #主要的配置文件目录 html #nginx的默认发布目录,部署完后 网站会在这个目录 ...
- Nginx配置文件语法教程
Nginx的配置文件在一开始可能真的不太好理解,就像当初开始使用Apache那样,像JSON但却不是.可以说是Nginx的一种专门语言,仅为Nginx服务的. 市面上基本都是写了一点不写一点的教程,基 ...
- nginx之旅(第一篇):nginx下载安装、nginx启动与关闭、nginx配置文件详解、nginx默认网站
一.nginx下载安装 版本nginx 1.15.5 系统环境centos7.5(本机ip192.168.199.228) 关闭selinux 和防火墙firewall 1.下载 wget http: ...
- Nginx配置文件nginx.conf中文详解(转)
######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...
随机推荐
- (转)matplotlib实战
原文:https://www.cnblogs.com/ws0751/p/8361330.html https://www.cnblogs.com/ws0751/p/8313017.html---mat ...
- 012-Shell 提示确认(Y / N,YES / NO)
例1:确认提示(一次) 这个示例代码将为确认提示一次,如果你给输入错误,程序会以状态1退出.这个例子将只接受Y或N或YES或NO(不区分大小写). #!/bin/bash read -r -p &qu ...
- Angularjs 标签使用整理
持续更新..... 一.select setmealList为接收到的集合数据,sname 是要显示的字段,Object属性 套餐类型:<select style="width: 15 ...
- Python爬虫笔记技术篇
目录 前言 requests出现中文乱码 使用代理 BeautifulSoup的使用 Selenium的使用 基础使用 Selenium获取网页动态数据赋值给BeautifulSoup Seleniu ...
- 用于抓取vijos所有题目信息的node.js脚本
代码如下: var superagent = require('superagent'); var fs = require('fs'); /* fetch_vijos_problems 这个脚本用于 ...
- nginx下只能通过域名,禁止使用ip访问
今天来了一个需求,ip访问返回500,域名访问正常,只需在nginx.conf中添加 server { listen 80 default; #default 必须加的 return 500; } 也 ...
- 第07组 Beta冲刺(2/4)
队名:秃头小队 组长博客 作业博客 组长徐俊杰 过去两天完成的任务:学习了很多东西 Github签入记录 接下来的计划:继续学习 还剩下哪些任务:后端部分 燃尽图 遇到的困难:自己太菜了 收获和疑问: ...
- maven设置阿里云仓库
到maven安装目录的conf下setting.xml文件 找到mirrors标签中添加 <mirror> <id>nexus-aliyun</id> <mi ...
- Xcode使用 Organizer 分析 Crash logs
xcode下载地址 https://developer.apple.com/download/more/
- AppCrawler安装使用
百度网盘: https://pan.baidu.com/s/1bpmR3eJ mac下安装appium 真机或者模拟器均可. 确保adb devices可以看到就行 启动appium 启动appium ...