请参考如下内容:
//////////////////////////////////////begin//////////////////////////////////////
#user nobody;
worker_processes 8;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 4096;
}
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;
#limit_zone ofmag_down $binary_remote_addr 10m;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
#gzip_min_length 1k;
gzip_min_length 0;
gzip_buffers 4 16k;
gzip_comp_level 3;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png application/vnd.ms-fontobject application/x-font-ttf image/svg+xml;
gzip_vary off;
gzip_disable "MSIE [1-6]\.";
upstream webtoolsserver {
ip_hash;
server 192.168.0.89:8443 max_fails=3 fail_timeout=30s;
server 192.168.0.87:8443 max_fails=3 fail_timeout=30s;
}
upstream imagesserver {
#the default strategy is round-robin
#ip_hash;
least_conn;
server 192.168.0.89:8080 max_fails=3 fail_timeout=30s;
server 192.168.0.87:8080 max_fails=3 fail_timeout=30s;
}
upstream espluginserver {
ip_hash;
server 192.168.0.43:9200 max_fails=3 fail_timeout=30s;
server 192.168.0.87:9200 max_fails=3 fail_timeout=30s;
}
###for http protocol
server {
listen 80;
server_name demo.yourdomain.com;
# ## setting http header property =begin=
server_tokens off;
add_header Cache-Control 'no-cache, no-store, must-revalidate';
add_header X-XSS-Protection '1; mode=block';
add_header X-Content-Type-Options 'nosniff';
add_header X-Frame-Options 'sameorigin';
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains';
add_header Expires '-1';
add_header Pragma 'no-cache';
add_header X-Permitted-Cross-Domain-Policies 'master-only';
# ## setting http header property =end=
# fragement for ssl =begin=
# rewrite ^(.*)$ https://$host$1 permanent;
# error_page 497 https://$host$uri?$args;
# return 301 https://$server_name$request_uri;
# fragement for ssl =end=
#charset koi8-r;
#access_log logs/host.access.log main;
#
location ^~/_ {
allow 192.168.1.0/24;
deny all;
proxy_pass http://espluginserver;
proxy_redirect default;
proxy_connect_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
root html;
index index.html index.htm;
}
location /images/{
proxy_pass http://imagesserver;
proxy_redirect default;
proxy_connect_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
root html;
index index.html index.htm;
}
location /webtools/{
allow 152.68.88.180;
allow 152.68.88.135;
allow 128.70.82.242;
allow 128.196.206.32;
deny all;
return 301 https://$server_name$request_uri;
proxy_pass https://webtoolsserver;
proxy_redirect default;
proxy_connect_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
root html;
index index.html index.htm;
}
###proxy path / in the last block
location / {
return 301 https://$server_name$request_uri;
proxy_pass http://webserver;
proxy_redirect default;
proxy_connect_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
root html;
index index.html index.htm;
}
#not configure ofmag's api proxy
location = /favicon.ico {
root html;
}
#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;
}
}
####for https protocol
server {
server_name demo.yourdomain.com;
# fragement for ssl =begin=
listen 443 ssl;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_certificate /opt/nginx/conf/server.crt;
ssl_certificate_key /opt/nginx/conf/server.key;
ssl_prefer_server_ciphers on;
# fragement for ssl =end=
#charset koi8-r;
#access_log logs/host.access.log main;
#
location /images/{
proxy_pass http://imagesserver;
proxy_redirect default;
proxy_connect_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
root html;
index index.html index.htm;
}
location /webtools/{
proxy_pass https://webtoolsserver;
proxy_redirect default;
proxy_connect_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
//////////////////////////////////////end////////////////////////////////////////
分享到:
相关推荐
Nginx配置http转https以及https访问http静态资源 Nginx是一款流行的开源Web服务器软件,常用于服务器端的反向代理、负载均衡、媒体流等功能。本文档将详细介绍如何使用Nginx配置http转https,以及https访问http静态...
现在的网站支持Https几乎是标配功能,Nginx能很好的支持Https功能。下面列举一个配置同时...废话不多说,下面直接贴一个Nginx支持Http和Https的配置,是我的wordpres网站支持Https的配置,大家何以参考。 server { #
nginx图片服务器配置和https配置
通过生成SSL证书、重新编译Nginx以添加SSL模块,以及编辑Nginx配置文件实现HTTPS支持和负载均衡功能。此外,还提供了Nginx的基本操作命令,包括启动、停止和重启等。这些步骤和配置为构建安全可靠的Web服务器提供了...
如果你看到“配置文件测试成功”且Nginx成功重新加载,那么恭喜你,你已经成功地配置了Nginx以支持HTTPS。现在,访问你的域名时,浏览器将显示一个绿色的小锁图标,表明连接是安全的。 在实际环境中,你可能还需要...
要使Nginx能够同时监听HTTP和HTTPS,我们需要在server块中同时使用listen指令监听80和443端口,并且对于443端口,需要指定ssl证书和密钥。这样配置后,Nginx可以处理HTTP请求,并对HTTPS请求进行加密处理。特别的,...
在本文中,我们将深入探讨如何在CentOS Linux系统上安装和配置Nginx,并提供一些基本的示例。Nginx是一款高性能的Web服务器和反向代理服务器,因其高效的性能和稳定性而广受欢迎。 首先,让我们按照步骤安装Nginx:...
本文主要介绍了如何使用Nginx配置SSL以实现HTTPS访问,这对于初学者来说是一份非常实用的指南。首先,我们需要理解HTTPS的重要性,它通过SSL协议在HTTP基础上增加了数据加密和服务器身份验证,确保了数据传输的安全...
通过以上步骤,你就成功地在Windows环境下的Nginx中配置了HTTPS以及实现了在同一端口上监听多个虚拟主机。记得定期检查并更新SSL证书,以确保网站的安全性。同时,根据实际需求,还可以对Nginx配置进行更复杂的优化...
以上步骤涵盖了在Windows和Linux环境下配置Nginx作为HTTPS反向代理并将请求转发至Tomcat HTTP服务器的过程。正确配置后,用户可以通过HTTPS协议访问部署在Tomcat上的应用,提高了安全性。此外,通过调整Nginx的配置...
3. **编辑Nginx配置文件**:找到Nginx的配置文件,通常是`/etc/nginx/nginx.conf`或`/usr/local/nginx/conf/nginx.conf`。添加一个新的`server`块,配置如下: ```nginx server { listen 80; listen 443 ssl; # ...
总结来说,这份文档详细介绍了在nginx环境中配置微信小程序https服务的步骤和要点,包括https的基本配置、静态文件访问映射、二维码扫描校验文件配置和反向代理设置。了解并掌握这些知识点对于开发和维护安全的微信...
多域名多服务模块一个80端口入口的配置样例。
2. Nginx 的安装和配置:使用 ./configure 命令来编译 Nginx,添加 --with-http_stub_status_module 和 --with-http_ssl_module 选项来支持 HTTPS 访问,并配置 Nginx 的安装目录为 /usr/local/nginx。 3. Nginx ...
Nginx 是一款高性能的 HTTP 和反向代理服务器,常被用来部署 web 应用,包括 Vue 项目。SSL(Secure Sockets Layer)和其继任者 TLS(Transport Layer Security)则是用于在互联网上提供安全通信的标准,通过 HTTPS ...
接着,我们需要安装一些依赖项,以便后续安装Nginx和配置HTTPS。这些依赖包括`epel-release`和`openssl`,它们提供了额外的软件包和必要的加密库: ```bash sudo dnf install epel-release -y sudo dnf install ...
阿里云服务器配置Nginx与HTTPS的流程是一个关键任务,对于提供安全的Web服务至关重要。以下将详细解释如何在CentOS7系统上进行这一过程。 首先,为了安装Nginx,你需要确保系统拥有必要的依赖库。运行以下命令来...