#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
 
upstream websocket {
server 192.168.9.201:8667;
}
server {
listen 80;
server_name 192.168.9.201;
rewrite ^(.*) https://$server_name$1 permanent; #强制http 跳转到https地址
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
        index index.html;
    root /opt/nginx-web/iphm/;
            autoindex on;
        #rewrite ^(.*)$ https://$host$1 permanent;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location /config {
         index index.html;
root /opt/nginx-web/config/;
autoindex on;
}
 
     location ^~ /websocket/alarm {
     proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}       
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
    server {
listen 8888;
        server_name 192.168.9.201;
rewrite ^(.*) https://$server_name:888$1 permanent;
location / {
         index index.html;
root /opt/nginx-web/config/;
autoindex on;
}
}
server {
listen 8889;
        server_name localhost;
location / {
         index index.html;
root /opt/nginx-web/diagnostic/;
autoindex on;
}
}
#HTTPS server
 
    server {
        listen 3001;
        server_name localhost;
        location / {
            #index index.html;
            #root /opt/nginx-web/iphm/;
            proxy_pass http://192.168.9.10:8102;
        }
    }
    # HTTPS server
#
server {
listen 443 ssl;
server_name 192.168.9.201;
ssl on;
ssl_certificate /usr/local/webserver/nginx/keys/server.crt;
ssl_certificate_key /usr/local/webserver/nginx/keys/server.key;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
# location /saml {
# proxy_pass http://192.168.70.34:8104;
# }
# location /sso {
# proxy_pass http://192.168.70.34:8104;
# }
location / {
root /opt/nginx-web/iphm;
index index.html;
autoindex on;
}
location /grafana {
rewrite ^(/grafana)(.*)$ $2 break;
proxy_pass http://192.168.9.201:3000;
}
location /zuul {
rewrite ^(/zuul)(.*)$ $2 break;
proxy_pass http://192.168.9.10:8102;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~ /websocket/alarm {
     proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
        error_log logs/error_8889.log error;
}
server {
listen 888 ssl;
server_name 192.168.9.201;
ssl on;
ssl_certificate /usr/local/webserver/nginx/keys/server.crt;
ssl_certificate_key /usr/local/webserver/nginx/keys/server.key;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
# location /saml {
# proxy_pass http://192.168.70.34:8104;
# }
# location /sso {
# proxy_pass http://192.168.70.34:8104;
# }
location / {
root /opt/nginx-web/config;
index index.html;
autoindex on;
}
        error_log logs/error_888.log error;
}
server {
listen 300 ssl;
server_name 192.168.9.201;
ssl on;
ssl_certificate /usr/local/webserver/nginx/keys/server.crt;
ssl_certificate_key /usr/local/webserver/nginx/keys/server.key;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
# location /saml {
# proxy_pass http://192.168.70.34:8104;
# }
# location /sso {
# proxy_pass http://192.168.70.34:8104;
# }
location / {
proxy_pass http://192.168.9.201:3000$request_uri;
}
location ^~/pubilc/ {
proxy_pass http://192.168.9.201:3000$request_uri;
}
        error_log logs/error_300.log error;
}
}

nginx 配置 HTTPS 及http 强制跳转https.的更多相关文章

  1. windwos下nginx 配置https并http强制跳转https

    windwos下nginx  配置https并http强制跳转https 一.首先配置证书文件 申请证书文件,这里就不做详细过程了,直接看证书文件结果. 这是两个证书的关键文件 打开ngxin下con ...

  2. nginx开启HSTS让浏览器强制跳转HTTPS访问

    在上一篇文章中我们已经实现了本地node服务使用https访问了,看上一篇文章 效果可以看如下: 但是如果我们现在使用http来访问的话,访问不了.如下图所示: 因此我现在首先要做的是使用nginx配 ...

  3. tomcat配置https 和 http强制跳转https

    https是http+ssl的可进行加密传输,身份认证的网络协议,防止数据在传输过程中被窃取.因此,https将得到越来越广泛的应用,下面是如何配置tomcat服务器让http自动转到https的步骤 ...

  4. nginx配置http强制跳转https

    nginx配置http强制跳转https 网站添加了https证书后,当http方式访问网站时就会报404错误,所以需要做http到https的强制跳转设置. 一.采用nginx的rewrite方法 ...

  5. (转)Nginx的https配置记录以及http强制跳转到https的方法梳理

    Nginx的https配置记录以及http强制跳转到https的方法梳理 原文:http://www.cnblogs.com/kevingrace/p/6187072.html 一.Nginx安装(略 ...

  6. 解决:ngxin做http强制跳转https,接口的POST请求变成GET

    域名配置了http强制跳转htpps后发现app发起post请求会出现405错误. 所以怀疑是http强制跳转https出现了问题.修改nginx配置如下即可解决: server { listen ; ...

  7. ngxin做http强制跳转https,接口的POST请求变成GET

    http强制跳转https出现了问题.修改nginx配置如下即可解决: server { listen 80; server_name *.snsprj.cn; return 307 https:// ...

  8. 开启HSTS让浏览器强制跳转HTTPS访问

    开启HSTS让浏览器强制跳转HTTPS访问 来源 https://www.cnblogs.com/luckcs/articles/6944535.html 在网站全站HTTPS后,如果用户手动敲入网站 ...

  9. Nginx的https配置记录以及http强制跳转到https的方法梳理

    一.Nginx安装(略)安装的时候需要注意加上 --with-http_ssl_module,因为http_ssl_module不属于Nginx的基本模块.Nginx安装方法: 1 2 # ./con ...

随机推荐

  1. 二十八、linux下权限管理chmod

    (1)查看权限 终端下需要查看文件或文件夹的权限时,可以使用ll查看当前目录的各文件权限. 如图,r代表读取权限,w代表写入权限,x代表执行权限:-代表普通文件,d代表文件夹.使用命令chmod可以修 ...

  2. React文档(十九)不使用ES6

    通常你会将一个React组件定义成一个普通的js类: class Greeting extends React.Component { render() { return <h1>Hell ...

  3. MySQL Packets larger than max_allowed_packet are not allowed

    MySQL的一个系统参数:max_allowed_packet,其默认值为1048576(1M), 查询:show VARIABLES like '%max_allowed_packet%'; 修改此 ...

  4. PAT 1148 Werewolf - Simple Version

    1148 Werewolf - Simple Version (20 分)   Werewolf(狼人杀) is a game in which the players are partitioned ...

  5. Django 之 cookie和session

    一. Cookie 1.Cookie的由来 因为HTTP协议是无状态的,无状态的意思就是每次请求都是独立的,它的执行情况和结果与前面的请求和之后的请求都无直接关系,也不会受前后请求响应情况直接影响.简 ...

  6. Webpack学习-工作原理(下)

    继上篇文章介绍了Webpack的基本概念,完整流程,以及打包过程中广播的一些事件的作用,这篇文章主要讲生成的chunk文件如何输出成具体的文件.分同步和异步两种情况来分析输出的文件使用的webpack ...

  7. css属性应用bug大杂烩(后续继续更新)

    一.Flex布局使用时的坑: 1.常见的左右分布的flex布局中,左侧给定宽度,右侧占满剩余空间,但当右侧中文字内容很多时,会挤占左侧空间,时左侧不能按照定宽显示. <style> .fa ...

  8. MySQL—ORM框架,sqlalchemy模块

    武老师博客:ORM框架介绍 import os #1.当一类函数公用同样参数时候,可以转变成类运行 - 分类 #2.面向对象: 数据和逻辑组合在一起了 #3. 一类事物共同用有的属性和行为(方法) # ...

  9. 什么样的类才算是一种可重用的组件,即JavaBean?

    每一个类实现了Bean的规范才可以由Spring来接管,那么Bean的规范是什么呢? 必须是个公有(public)类 有无参构造函数 用公共方法暴露内部成员属性(getter,setter) 实现这样 ...

  10. [线段树]HDU-1754板子题入门ver

    HDU-1754 线段树数组请开到四倍 众所周知数组开小会导致re tle wa等一系列问题orz 板子就是板子,数组从零开始或是从一开始都没什么问题,就是2*root+1还是2*root+2的问题. ...