NGINX作为代理服务器绕过https

NGINX作为代理服务器绕过https,nginx,Nginx,我使用nginx作为常规代理服务器。但是,它只适用于http,而不适用于https。它返回https请求的错误页面。是否有办法配置NGINX使其绕过https worker_processes auto; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65

我使用nginx作为常规代理服务器。但是,它只适用于http,而不适用于https。它返回https请求的错误页面。是否有办法配置NGINX使其绕过https

worker_processes auto;
events {
  worker_connections 1024;
}


http {
  include mime.types;
  default_type application/octet-stream;
  sendfile on;
  keepalive_timeout 65;

  server {
     resolver 114.114.114.114;
     listen 8228;
     server_name localhost;
     location / {
       proxy_pass $scheme://$http_host$request_uri;
       proxy_set_header Host $http_host;
       proxy_buffers 256 4k;
     }

  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
     root html;
  }
  }

您必须使用https相关设置添加新的
服务器
位置,这可能会完成以下工作:

server {
   resolver 114.114.114.114;

   // note the port is changed, you can't serve HTTP and HTTPS on same port
   listen 8229 ssl;

   // here you must place valid certificates (may be self-singed)
   // startssl example:
   // # (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null
   ssl_certificate /etc/nginx/domain.pem;

   // private key decoded, example
   // # openssl rsa -in decoded.key -out domain.key
   ssl_certificate_key /etc/nginx/domain.key;

   server_name localhost;

   location / {
       proxy_pass $scheme://$http_host$request_uri;
       proxy_set_header Host $http_host;
       proxy_buffers 256 4k;
   }

有很多可选的HTTPS配置参数,您必须在生产中使用,以确保足够的安全性,我已经在github上通过链接介绍过,这也是一个很好的起点。

您必须添加新的
服务器
位置和HTTPS相关设置,这可能会完成以下工作:

server {
   resolver 114.114.114.114;

   // note the port is changed, you can't serve HTTP and HTTPS on same port
   listen 8229 ssl;

   // here you must place valid certificates (may be self-singed)
   // startssl example:
   // # (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null
   ssl_certificate /etc/nginx/domain.pem;

   // private key decoded, example
   // # openssl rsa -in decoded.key -out domain.key
   ssl_certificate_key /etc/nginx/domain.key;

   server_name localhost;

   location / {
       proxy_pass $scheme://$http_host$request_uri;
       proxy_set_header Host $http_host;
       proxy_buffers 256 4k;
   }

有很多可选的HTTPS配置参数,您必须在生产中使用,以确保足够的安全性,我已经在github上通过链接介绍过,这也是一个很好的起点。

您必须添加新的
服务器
位置和HTTPS相关设置,这可能会完成以下工作:

server {
   resolver 114.114.114.114;

   // note the port is changed, you can't serve HTTP and HTTPS on same port
   listen 8229 ssl;

   // here you must place valid certificates (may be self-singed)
   // startssl example:
   // # (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null
   ssl_certificate /etc/nginx/domain.pem;

   // private key decoded, example
   // # openssl rsa -in decoded.key -out domain.key
   ssl_certificate_key /etc/nginx/domain.key;

   server_name localhost;

   location / {
       proxy_pass $scheme://$http_host$request_uri;
       proxy_set_header Host $http_host;
       proxy_buffers 256 4k;
   }

有很多可选的HTTPS配置参数,您必须在生产中使用,以确保足够的安全性,我已经在github上通过链接介绍过,这也是一个很好的起点。

您必须添加新的
服务器
位置和HTTPS相关设置,这可能会完成以下工作:

server {
   resolver 114.114.114.114;

   // note the port is changed, you can't serve HTTP and HTTPS on same port
   listen 8229 ssl;

   // here you must place valid certificates (may be self-singed)
   // startssl example:
   // # (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null
   ssl_certificate /etc/nginx/domain.pem;

   // private key decoded, example
   // # openssl rsa -in decoded.key -out domain.key
   ssl_certificate_key /etc/nginx/domain.key;

   server_name localhost;

   location / {
       proxy_pass $scheme://$http_host$request_uri;
       proxy_set_header Host $http_host;
       proxy_buffers 256 4k;
   }


对于HTTPS配置,有很多可选参数,您必须在生产中使用,以确保足够的安全性。我已经在github gist上通过链接进行了描述,这也是一个很好的起点。

您是否正在制作反向代理?常规代理服务器?这个重定向是怎么回事?只是google.com,还是其他什么?我只是把nginx作为一个常规的代理服务器。它重定向用户请求的所有内容并返回响应。请将整个配置发布到pastebin。它在443端口上捕获请求吗?@Dmitry Verkhoturov谢谢,我粘贴了整个配置。你必须在443上监听并设置ssl。你在制作反向代理吗?常规代理服务器?这个重定向是怎么回事?只是google.com,还是其他什么?我只是把nginx作为一个常规的代理服务器。它重定向用户请求的所有内容并返回响应。请将整个配置发布到pastebin。它在443端口上捕获请求吗?@Dmitry Verkhoturov谢谢,我粘贴了整个配置。你必须在443上监听并设置ssl。你在制作反向代理吗?常规代理服务器?这个重定向是怎么回事?只是google.com,还是其他什么?我只是把nginx作为一个常规的代理服务器。它重定向用户请求的所有内容并返回响应。请将整个配置发布到pastebin。它在443端口上捕获请求吗?@Dmitry Verkhoturov谢谢,我粘贴了整个配置。你必须在443上监听并设置ssl。你在制作反向代理吗?常规代理服务器?这个重定向是怎么回事?只是google.com,还是其他什么?我只是把nginx作为一个常规的代理服务器。它重定向用户请求的所有内容并返回响应。请将整个配置发布到pastebin。它在443端口上捕获请求吗?@Dmitry Verkhoturov谢谢,我粘贴了整个配置。你必须在443上监听,还要设置ssl。