0

I have been trying to configure nginx to act as a web proxy (like squid) to be able to modify headers. It is working with http, but https shows "Server not found". Also, I can access directly with the url and it downloads https resources, if I reload it fails to load https resources...... what am I doing wrong?

this is my nginx.conf:

worker_processes  1;

events {
    worker_connections  1024;
}

http {
types_hash_max_size 4096;
include       mime.types;
default_type  application/octet-stream;

sendfile        on;
keepalive_timeout  65;

gzip  on;

upstream @squid {
    server 127.0.0.1:3128;
}

server {
    listen 3120 ;

    ssl_certificate           /etc/nginx/certs/cert.crt;
    ssl_certificate_key       /etc/nginx/certs/cert.key;

    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_prefer_server_ciphers on;

    location / {
    resolver 8.8.8.8 192.168.1.254;
    #proxy_bind 127.0.0.1:3128;
    proxy_http_version 1.1;
    proxy_pass $scheme://$host$request_uri;

        #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_set_header Request-URI $request_uri;

        proxy_redirect off;
            #proxy_pass http://$host$request_uri;
    }
}
}
1

You have not enabled SSL in your nginx server {} block.

The line that needs changing:

listen 3120 ;

should instead be:

listen 3120 ssl;

This will enable SSL for that nginx server {} block, but if you have not noticed already, HTTP (non-SSL) will stop working on port 3120.

You may be able to set that server {} block to listen to both HTTP and HTTPS with the following:

listen 3120 ;
listen 3121 ssl;

but as you notice, it requires different ports.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.