1.主配置/etc/nginx.conf

#/etc/nginx/nginx.conf 

user nginx;
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"'; log_format main '[$time_iso8601] $remote_addr "$request" '
'$status $request_time $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; gzip on;
gzip_comp_level 6;
gzip_min_length 1024;
gzip_types *;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048; proxy_headers_hash_max_size 1024;
proxy_headers_hash_bucket_size 512;
server_names_hash_bucket_size 512; 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;
include /etc/nginx/vhosts/*.conf;
}

2.网站配置

# /etc/nginx/vhosts/my.domain.com.conf

server {
listen ;
server_name my.domain.com; return https://$host$request_uri; access_log /var/log/nginx/my.domain.com.access.log main;
error_log /var/log/nginx/my.domain.com.error.log; location / {
proxy_pass http://localhost:3031/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
} location /static/ {
alias /var/www/my.domain.com/static/;
autoindex off;
} location /.well-known/ {
alias /var/www/my.domain.com/.well-known/;
autoindex off;
}
} server {
listen ssl;
server_name my.domain.com; access_log /var/log/nginx/my.domain.com.access.log main;
error_log /var/log/nginx/my.domain.com.error.log; ssl_certificate "/root/.getssl/my.domain.com/my.domain.com.chain.crt";
ssl_certificate_key "/root/.getssl/my.domain.com/my.domain.com.key"; ssl_session_cache shared:SSL:20m;
ssl_session_timeout 60m;
ssl_protocols TLSv1 TLSv1. TLSv1.;
ssl_prefer_server_ciphers on;
ssl_ciphers "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS"; location / {
proxy_pass http://localhost:3031/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
} # proxy pass php
location ~ \.php$ {
fastcgi_pass 127.0.0.1:;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} location /static/ {
alias /var/www/my.domain.com/static/;
autoindex off;
} location /.well-known/ {
alias /var/www/my.domain.com/.well-known/;
autoindex off;
} location ~* \.html$ {
root /var/www/my.domain.com/;
autoindex off;
} location /robots.txt {
root /var/www/my.domain.com/;
autoindex off;
}
}

Nginx Configure的更多相关文章

  1. NGINX configure auto generator

    NGINX configure auto generator The easiest way to configure a performant, secure, and stable NGINX s ...

  2. Nginx Configure时配置

    Configure Arguments Configure arguments common for nginx binaries from pre-built packages for stable ...

  3. nginx configure fastdfs + SSL

    ./configure \ --prefix=/usr/local/nginx \ --with-http_stub_status_module \ --with-http_ssl_module \ ...

  4. nginx configure参数

    下面是nginx源码程序的configure参数: --prefix= 指向安装目录.默认为:/usr/local/nginx --sbin-path= 指定执行程序文件存放位置.默认为:prefix ...

  5. nginx configure 错误记录

    1.the HTTP rewrite module requires the PCRE library. ./configure: error: the HTTP rewrite module req ...

  6. centos 7.0 安装nginx 1.9.10

    可以参考以前安装成功的案例 centos 7.0 nginx 1.7.9成功安装过程 官网下载 http://nginx.org/en/download.html nginx下载位置 /usr/loc ...

  7. Nginx中文详解、配置部署及高并发优化

      一.Nginx常用命令: 1. 启动 Nginx          /usr/local/nginx/sbin/nginxpoechant@ubuntu:sudo ./sbin/nginx2. 停 ...

  8. ansible 初探nginx安装

    我的配置: /etc/hosts: /etc/ansible/hosts: nglinx安装包: ansible自动化安装nginx: 1.安装ansible. 2.创建目录结构: mkdir -p ...

  9. centos6.4下安装php7+nginx+mariadb环境

    一,安装php71,创建php用户和用户组,并在github下载php7源码#新建php用户和php组# groupadd -r php && useradd -r -g php -s ...

随机推荐

  1. Python Type Hint类型注解

    原文地址:https://realpython.com/python-type-checking/ 在本指南中,你将了解Python类型检查.传统上,Python解释器以灵活但隐式的方式处理类型.Py ...

  2. Ajax&Json案例

    案例: * 校验用户名是否存在 1. 服务器响应的数据,在客户端使用时,要想当做json数据格式使用.有两种解决方案: 1. $.get(type):将最后一个参数type指定为"json& ...

  3. flask-restful 初探

    flask-restful 是 Flask 的一个用于支持 RESTful 的插件. 刚开始用对我来说还是比较坑的... 目录结构 / /test /test/common /__init__.py ...

  4. 手写node可读流之流动模式

    node的可读流基于事件 可读流之流动模式,这种流动模式会有一个"开关",每次当"开关"开启的时候,流动模式起作用,如果将这个"开关"设置成 ...

  5. 前端每日实战:102# 视频演示如何用纯 CSS 创作一个小和尚

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/oMmYXp 可交互视频 此视频是可 ...

  6. html+css布局类型

    一.单列布局 1.代码如下 <!doctype html> <html> <head> <meta charset="utf-8"/> ...

  7. Dubbo 入门-细说分布式与集群

    什么是Dubbo Dubbo是一款高性能.轻量级的开源Java RPC框架,它提供了三大核心能力:面向接口的远程方法调用,智能容错和负载均衡,以及服务自动注册和发现. 什么是RPC RPC全称(Rem ...

  8. vue_相同组件,不同url跳转不重新渲染的解决方法

    最近写的这个项目,有很多下拉菜单,每个菜单会有相应的两种类型.现在产品的需求是,跳转到不同的类型 需要页面重新渲染数据 那么问题来了. 我试了好几种方法,用watch监听路由去判断,但是发现输在inp ...

  9. [每日一题系列] LeetCode 1071. 字符串的最大公因子

    题目 对于字符串 S 和 T,只有在 S = T + ... + T(T 与自身连接 1 次或多次)时,我们才认定 "T 能除尽 S". 返回最长字符串 X,要求满足 X 能除尽 ...

  10. 【Vue】---- 手动封装on,emit,off

    一.概念 1. $on("事件名称",回调函数) 事件绑定,一个事件名称上面可能绑定多个函数 2. $emit("事件名称",需要传递的值) 事件触发时,会触发 ...