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. JVM优化之垃圾收集器以及内存分配

    在jvm中,实现了多种垃圾收集器,包括:串行垃圾收集器.并行垃圾收集器.CMS(并发)垃圾收集器.G1垃圾收集器,接下来,我们一个个的了解学习. 串行垃圾收集器 串行垃圾收集器,是指使用单线程进行垃圾 ...

  2. Web图片资源的加载与渲染时机

    此文研究页面中的图片资源的加载和渲染时机,使得我们能更好的管理图片资源,避免不必要的流量和提高用户体验. 浏览器的工作流程 要研究图片资源的加载和渲染,我们先要了解浏览器的工作原理.以Webkit引擎 ...

  3. HTTP入门(一):在Bash中curl查看请求与响应

    HTTP入门(一):在Bash中curl查看请求与响应 本文简单总结HTTP的请求与响应. 本文主要目的是对学习内容进行总结以及方便日后查阅. 详细教程和原理可以参考HTTP文档(MDN). 本文版权 ...

  4. OpenCV中Mat的基本用法:创建、复制

    OpenCV中Mat的基本用法:创建.复制 一.Mat类的创建: 1.方法一: 通过读入一张图像,直接将其转换成Mat对象. Mat image = imread("test.jpg&quo ...

  5. Java继承中构造器的调用原理

    Java的继承是比较重要的特性,也是比较容易出错的地方,下面这个例子将展示如果父类构造器中调用被子类重写的方法时会出现的情况: 首先是父类: public class test { void fun( ...

  6. cocos2d-x android 入门

    前一段时间使用传统方式做了一个CS软件,发现 UI 显示的比较慢,突发奇起,开始研究起来 GPU 加速,最后开始学习 cocos2dx. 开发环境以最新的 Cocos2d-x 3.17.1 Andro ...

  7. eclipse代码提示完善

    转载请注明出处:https://www.cnblogs.com/Higurashi-kagome/p/12263267.html 1.参考https://blog.csdn.net/ithomer/a ...

  8. 记一次在新服务器上搭建lnmp的过程

    背景: 前不久阿里云在做活动,200+一台服务器三年,于是果断入手了一台. 今天有空就在服务器上把lnmp环境给装了,之前为了了解安装过程,在别的机器上尝试过单独安装nginx.mysql.php,虽 ...

  9. 关于WPF System.windows.Media.FontFamily 的类型初始值设定项引发异常问题解决方法

    造成原因:此问题的根本原因是.NET Framework January 2018 Rollup(KB4055002)与已安装的.NET Framework 4.7.1产品版本之间的MSI安装交互.R ...

  10. 再刷JVM-JVM运行时数据区域

    前言 Java虚拟机在执行Java程序的过程中会把它所管理的内存划分为若干个不同的数据区域.这些区域有各自的用途,以及创建和销毁的时机,有的区域随着虚拟机进程的启动而一直存在,有些区域则是依赖用户线程 ...