I am trying to setup a proxy server which will handle both http and https requests. The server will also cache the response for future usage.
I am able to successfully implement the proxy with http request but I am not able to configure the https.
For all the https request that I make after setting up the proxy in my browser I receive a 400 against all the requests
Here is the successful implementation of http requests
server {
listen 8080;
server_name localhost;
allow {some private IP for Testing};
deny all;
location / {
resolver 8.8.8.8;
proxy_cache browser;
proxy_pass http://$http_host$uri$is_args$args;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
}
}
This is what I get in the access logs - Bing and youtube are from browser.
"CONNECT log.olark.com:443 HTTP/1.1" 400 325 "-" "-" "-"
"CONNECT nrpc.olark.com:443 HTTP/1.1" 400 325 "-" "-" "-"
"CONNECT www.bing.com:443 HTTP/1.0" 400 325 "-" "-" "-"
"CONNECT www.youtube.com:443 HTTP/1.0" 400 325 "-" "-" "-"
"CONNECT nrpc.olark.com:443 HTTP/1.1" 400 325 "-" "-" "-"
"CONNECT plus.google.com:443 HTTP/1.1" 400 325 "-" "-" "-"
Here is the https section of the nginx.conf file
server {
listen {Server IP Here}:443 ssl;
server_name {Server IP Here};
allow {Some Private IP for testing};
deny all;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
#ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/ssl/dhparams.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
keepalive_timeout 70;
location / {
resolver 8.8.8.8;
proxy_cache browser;
proxy_pass https://$http_host$uri$is_args$args;
proxy_ssl_certificate /etc/nginx/ssl/nginx.crt;
proxy_ssl_certificate_key /etc/nginx/ssl/nginx.key;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
proxy_ssl_trusted_certificate /etc/nginx/ssl/nginx.crt;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
proxy_set_header Accept-Encoding "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
}
I have tried the upstream key as well by adding <a href="http://upstreamname" rel="nofollow noreferrer">http://upstreamname</a> in the proxy_pass key inside location key
upstream https_prox{
server 127.0.0.1;
}
server {
...
location / {
...
proxy_pass http://https_prox
...
}
}
Here is the the entire http section of the nginx.conf file for reference:
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
map $remote_addr $log_ip {
"{Some private Ip for testing}" 1;
default 0;
}
##
# Logging Settings
##
log_format custom_combined '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';
access_log /var/log/nginx/access.log custom_combined if=$log_ip;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
proxy_cache_path /home/{system_user}/nginx_cache levels=1:2 keys_zone=browser:8192m max_size=80g inactive=60m;
server {
listen 8080;
server_name localhost;
allow {Some private Ip for testing};
deny all;
location / {
resolver 8.8.8.8;
proxy_cache browser;
proxy_pass http://$http_host$uri$is_args$args;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
}
}
#upstream https_prox{
# server 127.0.0.1;
#}
server {
listen {Server Ip Here}:443 ssl;
server_name {Server Ip Here};
allow {Some private Ip for testing};
deny all;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
#ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/ssl/dhparams.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
keepalive_timeout 70;
location / {
resolver 8.8.8.8;
proxy_cache browser;
proxy_pass http://$http_host$uri$is_args$args;
proxy_ssl_certificate /etc/nginx/ssl/nginx.crt;
proxy_ssl_certificate_key /etc/nginx/ssl/nginx.key;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
proxy_ssl_trusted_certificate /etc/nginx/ssl/nginx.crt;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
proxy_set_header Accept-Encoding "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
}
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Note:
The Server has self signed certificates<br> Also domain name is not pointed as off now <br> Ubuntu 14.04 server and nginx at 1.10
I am able to successfully implement the proxy with http request but I am not able to configure the https.
For all the https request that I make after setting up the proxy in my browser I receive a 400 against all the requests
Here is the successful implementation of http requests
server {
listen 8080;
server_name localhost;
allow {some private IP for Testing};
deny all;
location / {
resolver 8.8.8.8;
proxy_cache browser;
proxy_pass http://$http_host$uri$is_args$args;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
}
}
This is what I get in the access logs - Bing and youtube are from browser.
"CONNECT log.olark.com:443 HTTP/1.1" 400 325 "-" "-" "-"
"CONNECT nrpc.olark.com:443 HTTP/1.1" 400 325 "-" "-" "-"
"CONNECT www.bing.com:443 HTTP/1.0" 400 325 "-" "-" "-"
"CONNECT www.youtube.com:443 HTTP/1.0" 400 325 "-" "-" "-"
"CONNECT nrpc.olark.com:443 HTTP/1.1" 400 325 "-" "-" "-"
"CONNECT plus.google.com:443 HTTP/1.1" 400 325 "-" "-" "-"
Here is the https section of the nginx.conf file
server {
listen {Server IP Here}:443 ssl;
server_name {Server IP Here};
allow {Some Private IP for testing};
deny all;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
#ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/ssl/dhparams.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
keepalive_timeout 70;
location / {
resolver 8.8.8.8;
proxy_cache browser;
proxy_pass https://$http_host$uri$is_args$args;
proxy_ssl_certificate /etc/nginx/ssl/nginx.crt;
proxy_ssl_certificate_key /etc/nginx/ssl/nginx.key;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
proxy_ssl_trusted_certificate /etc/nginx/ssl/nginx.crt;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
proxy_set_header Accept-Encoding "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
}
I have tried the upstream key as well by adding <a href="http://upstreamname" rel="nofollow noreferrer">http://upstreamname</a> in the proxy_pass key inside location key
upstream https_prox{
server 127.0.0.1;
}
server {
...
location / {
...
proxy_pass http://https_prox
...
}
}
Here is the the entire http section of the nginx.conf file for reference:
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
map $remote_addr $log_ip {
"{Some private Ip for testing}" 1;
default 0;
}
##
# Logging Settings
##
log_format custom_combined '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';
access_log /var/log/nginx/access.log custom_combined if=$log_ip;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
proxy_cache_path /home/{system_user}/nginx_cache levels=1:2 keys_zone=browser:8192m max_size=80g inactive=60m;
server {
listen 8080;
server_name localhost;
allow {Some private Ip for testing};
deny all;
location / {
resolver 8.8.8.8;
proxy_cache browser;
proxy_pass http://$http_host$uri$is_args$args;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
}
}
#upstream https_prox{
# server 127.0.0.1;
#}
server {
listen {Server Ip Here}:443 ssl;
server_name {Server Ip Here};
allow {Some private Ip for testing};
deny all;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
#ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/ssl/dhparams.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
keepalive_timeout 70;
location / {
resolver 8.8.8.8;
proxy_cache browser;
proxy_pass http://$http_host$uri$is_args$args;
proxy_ssl_certificate /etc/nginx/ssl/nginx.crt;
proxy_ssl_certificate_key /etc/nginx/ssl/nginx.key;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
proxy_ssl_trusted_certificate /etc/nginx/ssl/nginx.crt;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
proxy_set_header Accept-Encoding "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
}
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Note:
The Server has self signed certificates<br> Also domain name is not pointed as off now <br> Ubuntu 14.04 server and nginx at 1.10