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_ ...
随机推荐
- java获取ubuntu某个目录下的所有文件信息
java获取ubuntu某个目录下的所有文件信息 public List<VCFile> getAllFiles(String basicDirName) { List<VCFile ...
- Dockerfile实例
一.先看最简单的例子,定制nginx镜像,打印出 <h1>Hello, Docker!</h1> Dockerfile文件: FROM nginx RUN echo '< ...
- OpenShift 4.1 基本问题探索
因为在OpenShift 4.1环境中不建议直接登录集群主机操作,因此很多操作可能需要在外部的Client VM上完成.当然用rhel的worker node的同事也可以和原来习惯保持一致. 这里记录 ...
- IISExpress.无法启动IIS Express Web 服务器.Starting IIS Express... IIS Express is running
x 提示: 无法启动IIS Express Web 服务器. 来自IIS Express的输出: Starting IIS Express... IIS Express is running 总结: ...
- c#中Split 分离字符以及空格消除方法
1 split几种分离方法 1)用字符串分隔: using System.Text.RegularExpressions; string str="aaajsbbbjsccc& ...
- [LeetCode] 256. Paint House 粉刷房子
There are a row of n houses, each house can be painted with one of the three colors: red, blue or gr ...
- 【CUDA开发】 Check failed: error == cudaSuccess (8 vs. 0) invalid device function
最近在复现R-CNN一系列的实验时,配置代码环境真是花费了不少时间.由于对MATLAB不熟悉,实验采用的都是github上rbg大神的Python版本.在配置Faster R-CNN时,编译没有问题, ...
- VS+OpenGl 显示三维STL模型 代码
今天调出了用VS环境结合OpenGL glut工具包进行显示STL模型的模块,进行了渲染.效果: 如下,后期会进行进一步优化,先贴上: #ifndef DATA_H #define DATA_H st ...
- call、apply、bind的区别,模拟call、apply和bind的实现
bind:bind绑定完this的指向后会返回一个新的函数体,不会被立即调用 call&apply:绑定完this的指向后会立即调用 call与apply的区别: call:第 ...
- Python进阶:程序界的垃圾分类回收
垃圾回收是 Python 自带的机制,用于自动释放不会再用到的内存空间: 什么是内存泄漏呢? 内存泄漏,并不是说你的内存出现了信息安全问题,被恶意程序利用了,而是指程序本身没有设计好,导致程序未能释放 ...