Nginx http://到https://不包括路径

I am trying to clean up my nginx proxy 80 and proxy 443 files. The impetus for doing is is Certbot added SSL code in random spots.

  • I am trying to put all SSL related in my proxy 443 file
  • I want to leave only the redirects from http:// to https:// in my proxy 80 file.

The problem I am having is all my rewrite rules (except for the the home page) are no longer accessible when I make this change.

This is the content I want to keep in my proxy 80 file:

server {

    server_name example.com;
    listen *:80;

    return 301 https://$host$request_uri;

}

Then in my proxy 443 I have:

server {

    listen *:443 ssl;
    server_name example.com www.example.com;

    location / {
        proxy_pass https://1.2.3.4;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host example.com;

        proxy_redirect off;
    }

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

Somehow the path portion of the URL is lost. Is anyone able to sort out what has gone on? The web sites affected are PHP based and not programmed within the context of a frame work. What I see on is a '404' error.