Nginx配置同时支持http和https两种方式访问
http:
https:
Nginx的ssl模块安装
进入到目录的sbin目录下,输入
#注意这里是大写的V,小写的只显示版本号
./nginx -V
如果出现 (configure arguments: --with-http_ssl_module), 则已安装(下面的步骤可以跳过,直接进行第五步)。
一般情况下都是不存在ssl模块的,接下来进入到你的解压缩后的nginx目录,注意这里不是nginx安装目录,是解压缩后的目录。
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
然后执行
make
#切记不要执行make install,否则会重新安装nginx
接下来使用新的nginx文件替换掉之前安装目录sbin下的nginx,注意这里的替换的时候可以先将之前的文件备份下,停掉nginx服务。
./nginx -s stop #停止nginx服务#替换之前的nginx
cp /usr/nginx/objs/nginx /usr/local/nginx/sbin
成功之后,进入到nginx安装目录下,查看ssl时候成功
#注意这里是大写的V,小写的只显示版本号
./nginx -V
#可以看到这里出现了configure arguments: --with-http_ssl_module 证明已经安装成功
nginx.conf
#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;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;server {listen 80;server_name ip;#charset koi8-r;#access_log logs/host.access.log main;location / {proxy_pass http://ip:端口/;root html;index index.html index.htm;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {# deny all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server#server {listen 80;listen 443 ssl;server_name ip;location / {proxy_pass http://ip:端口/;}ssl_certificate /cert.pem;ssl_certificate_key /cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }}}
Nginx配置同时支持http和https两种方式访问相关推荐
- Nginx配置同一个域名同时支持http与https两种方式访问
Nginx配置同一个域名http与https两种方式都可访问,证书是阿里云上免费申请的 server { listen 80; listen 443 ssl; ssl on; server_name ...
- POI读取word文件,(支持HSSF和XSSF两种方式)
POI读取word文件,(支持HSSF和XSSF两种方式) 参考:HSSF,XSSF,SXSSF三种方式 1.引用maven(版本必须一致) <dependency><groupId ...
- spring支持事务管理的两种方式
转载:https://blog.csdn.net/bao19901210/article/details/41724355 事物管理对于企业应用来说是至关重要的,好使出现异常情况,它也可以保证数据的一 ...
- Code First02---CodeFirst配置实体与数据库映射的两种方式
Code First有两种配置数据库映射的方式,一种是使用数据属性DataAnnotation,另一种是Fluent API. 这两种方式分别是什么呢?下面进行一一解释: DataAnnotation ...
- SpringMVC 控制器默认支持GET和POST两种方式
在SpringMVC的controller中,@RequestMapping只写路径,不包含RequetMethod.GET和RequetMethod.POST,HttpServletRequest的 ...
- springmvc配置同时支持html和jspl两种格式的页面
通常情况下,springmvc返回一种格式的文件,通过配置前缀和后缀,相应controller层只需返回字符串,就可以跳转到相关页面. 有时候,项目中html和jsp页面同时存在,如果不做特殊配置,需 ...
- Neo4j的两种方式访问(嵌入式访问、服务器模式访问)-- java客户端连接和SpringBoot整合Neo4j
一.Neo4j数据库访问 1.Neo4j数据库访问 嵌入式数据库 服务器模式(通过REST的访问) 它是由应用程序的性质(neo4j是独立服务器 还是和程序在一起),性能,监控和数据安全性来决定架构选 ...
- nginx 之 http 转 https (两种方式)
方式一: #这种方法是http转发到https,但是http和https不能用同一个配置 server {listen 80;listen www.xxx.com:80; #此处添加你要该链接访问的域 ...
- CMAKE支持c++11的两种方式
全局设置 set (CMAKE_CXX_STANDARD 11) 注意:这种方式仅适用于cmake3.1之后 如果是老版本,稍微麻烦一些 include(CheckCXXCompilerFlag) C ...
最新文章
- android 自定义音乐圆形进度条,Android自定义View实现音频播放圆形进度条
- 一文带你搞懂 MySQL 分区!
- django中的缓存 单页面缓存,局部缓存,全站缓存 跨域问题的解决
- java实验报告 05 类与_java程序设计类与方法-java实验报告
- SL2_RedSkin
- 【面向过程编程】零钱通项目
- android创建类的包名称,如何知道/配置Xamarin Android生成的程序包名...
- 积分和人民币比率_通过比率路由到旧版和现代应用程序–通过Spring Cloud的Netflix Zuul...
- 兼容门:先卸载腾讯QQ,再卸载360软件!
- 堆优化的Dijkstra
- 【转载】SNMPv3 配置及snmpwalk命令信息获取
- 低功耗中的Isolation cells 和Level shifter cells
- 『杭电1166』敌兵布阵
- html按钮圆弧样式,几款不错的按钮样式汇总
- PIPI1091 编程课奖励(滚动数组+dp)
- centos6.5 ifconfig 显示为eth2,配置文件只有eth0
- 企业服务器固态硬盘寿命,SSD固态硬盘使用寿命短?_企业存储技术与评测-中关村在线...
- JS_微信公众号开发调用扫码支付功能
- Anaconda 使用 set CONDA_FORCE_32BIT=1 切换32位环境失败的解决方法
- crt格式证书转pem格式证书