0

I've Googled this problem and found lots of information about it. But for some reason no matter what I do it's not working for me. The following is my site.conf

server {
    listen 80;
server_name www3.mohave.gov;

return 301 https://$host$request_uri;

}

server{

listen       443 ssl http2; # default_server;
server_name  www3.mohave.gov;

access_log  /var/log/nginx/mohave_gov_access.log;
error_log   /var/log/nginx/mohave_gov_error.log debug;

include /etc/nginx/sites-available/mohave_gov_ssl.conf;
# root /var/www/html;


location /health {
    return 200 "healthy\n";
}

location / {
    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_buffers 16 4k;
    proxy_buffer_size 2k;       

    proxy_pass https://www.mohave.gov:443/;
    # proxy_pass https://www.mohave.gov/;
    # proxy_pass https://www.mohave.gov;
    # proxy_pass https://internal_ip:443/;
    # proxy_pass https://internal_ip/;
    proxy_read_timeout 60s;

}   

}

I'm trying hit the default page of

https://www3.mohave.gov and event the default page https://www3.mohave.gov/Default.aspx but no matter what I keep getting a 404. My proxy_pass samples are from what I've been reading throughout Google. I can ping the server www.mohave.gov from nginx server and verified it with the command:

telnet www.mohave.gov 443

which returns:

Trying 10.4.1.8... Connected to www.mohave.gov.

Any ideas or tips that help me solve this?

Update

Ok I think the problem is that the server I'm trying to reach only uses 443 and part of my researched showed that I need to put the pem certificate in the reverse proxy. I will try that and update

Update

When I reverse proxy to a site that accepts port 80 it works fine, but for SSL is the issue. I followed the following steps:

I export the certificate from the pfx using the following command:

Exporting the certificate only:
# openssl pkcs12 -in filename.pfx -clcerts -nokeys -out mohave.gov.pem

location / { 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_buffers 16 4k;
proxy_buffer_size 2k;       


proxy_ssl_trusted_certificate /etc/nginx/ssl/mohave_gov/5_13_2022/mohave.gov.pem;
proxy_ssl_verify  off;

# proxy_pass https://www.mohave.gov:443/;
proxy_pass https://www.mohave.gov/;
# proxy_pass https://10.4.1.8:443/;
# proxy_pass https://10.4.1.8/;
# proxy_pass https://10.4.1.8;
proxy_read_timeout 60s;

}

but I'm still getting a 404 error.

adviner
  • 155
  • 2
  • 3
  • 7

0 Answers0