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配置文件示例的更多相关文章

  1. uwsgi配置文件示例

    uwsgi配置文件参考 相关路径请根据自己项目的实际路径配置 在进行Nginx+uwsgi部署Django项目的时候,需要Nginx的配置中包含uwsgi的配置项,具体请查看另一篇:Nginx配置文件 ...

  2. NGINX配置文件优化示例

    Nginx主配置文件 upstream.conf配置文件 # server nginx配置文件最好分开写,不要把所有的逻辑都放在一个文件里面,会看着很麻烦,,之前我的配置文件都放一起了,,导致现在维护 ...

  3. 一、Nginx配置文件详解

    配置文件介绍 主要有两部分:分别是 main:主体部分 http{}:虚拟主机配置部分 配置指令主要以分号结尾:配置语法:directive value1 [value2 ....] 支持使用的变量 ...

  4. nginx配置文件中的location理解

    关于一些对location认识的误区 1. location 的匹配顺序是"先匹配正则,再匹配普通". 矫正: location 的匹配顺序其实是"先匹配普通,再匹配正则 ...

  5. nginx配置文件详解(三)

    nginx配置文件详细解析 nginx安装目录:  /usr/local/nginx 配置文件:  /usr/local/nginx/conf 目录下的 nginx.conf文件 nginx优化方法1 ...

  6. nginx入门示例(二)

    nginx使用域名访问 (Tip)      nginx目录解析 conf/nginx.conf   #主要的配置文件目录 html      #nginx的默认发布目录,部署完后 网站会在这个目录 ...

  7. Nginx配置文件语法教程

    Nginx的配置文件在一开始可能真的不太好理解,就像当初开始使用Apache那样,像JSON但却不是.可以说是Nginx的一种专门语言,仅为Nginx服务的. 市面上基本都是写了一点不写一点的教程,基 ...

  8. nginx之旅(第一篇):nginx下载安装、nginx启动与关闭、nginx配置文件详解、nginx默认网站

    一.nginx下载安装 版本nginx 1.15.5 系统环境centos7.5(本机ip192.168.199.228) 关闭selinux 和防火墙firewall 1.下载 wget http: ...

  9. Nginx配置文件nginx.conf中文详解(转)

    ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...

随机推荐

  1. bind 0.0.0.0的作用是什么呢?

    背景描述: 今天在看redis的内容,看到同事在配置文件中将bind配置为0.0.0.0进行监听,不明白什么意思就查询了下,在此记录下. 解释: 0.0.0.0在服务器的环境中,指的就是服务器上所有的 ...

  2. Python3 多线程(连接池)操作MySQL插入数据

    1.主要模块DBUtils : 允许在多线程应用和数据库之间连接的模块套件Threading : 提供多线程功能 2.创建连接池PooledDB 基本参数: mincached : 最少的空闲连接数, ...

  3. postman跳过登陆直接使用的办法

    新版的postman不再是Chrome的插件,而是一个独立的app.下载安装后会提示你注册账户或者登陆.在私有环境,例如实验室,或者单机调试,或者其他VPN隔离的内部环境,无法完成登陆操作. 解决办法 ...

  4. oracle 中decode的用法

    select decode(gg1.group_goods_amount, , , gg1.group_goods_amount) ; 这句话的意思是:如果group_goods_amount为0 则 ...

  5. jsp 记录

      前后端开发好久后,一直没怎么用前端开发了.最近任务比较急,又开始写jsp页面了... 1)jquery.validate.min.js 用法总结 https://www.cnblogs.com/x ...

  6. vagrant报错处理

    vagrant up报错 Warning: Authentication failure. Retrying...解决方案 http://www.cnblogs.com/zqifa/p/vagrant ...

  7. [LeetCode] 387. First Unique Character in a String 字符串的第一个唯一字符

    Given a string, find the first non-repeating character in it and return it's index. If it doesn't ex ...

  8. Consul ACL集群配置说明以及ACL Token的用法

    在上一篇文章里面,我们讲了如何搭建带有Acl控制的Consul集群.这一篇文章主要讲述一下上一篇文章那一大串配置文件的含义. 1.配置说明#1.1 勘误上一篇文章关于机器规划方面,consul cli ...

  9. 面试之leetcode链表

    1 数组 (1)数组的插入 如果是插入到最后,那么不用移动O(1),如果插入位置在中间为O(n).所以最好O(1),最坏O(N),平均O(N),为了插入能达到O(1),插入O(1).引入了链表 2 链 ...

  10. LeetCode 235. 二叉搜索树的最近公共祖先 32

    235. 二叉搜索树的最近公共祖先 235. Lowest Common Ancestor of a Binary Search Tree 题目描述 给定一个二叉搜索树,找到该树中两个指定节点的最近公 ...