ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Install Nginx as a Reverse Proxy on Fedora 27

    IT Discussion
    nginx fedora certbot fedora 27 reverse proxy guides real instructions how to
    16
    107
    22.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • black3dynamiteB
      black3dynamite
      last edited by

      No love for the awesome ed command? :grinning_face_with_smiling_eyes:
      https://www.gnu.org/software/ed/manual/ed_manual.html

      Seriously, what's up with the arguments about which editor is better?

      1 Reply Last reply Reply Quote 0
      • ObsolesceO
        Obsolesce @JaredBusch
        last edited by Obsolesce

        @jaredbusch said in Install Nginx as a Reverse Proxy on Fedora 27:

        @tim_g STFU already. No one fucking cares.

        Also get the fuck over yourself already.

        Aww, is someone pointing out some flaws / difference of opinion / misconceptions in something you like or prefer?

        Here's a guide for you:

        0_1524246626520_5e68a19a-f7d4-4d89-a211-fa9c4d9e225b-image.png

        JaredBuschJ 1 Reply Last reply Reply Quote 0
        • EddieJenningsE
          EddieJennings
          last edited by

          I've found a far better thread for discussing the merits of text editors. Enjoy 😄

          1 Reply Last reply Reply Quote 2
          • JaredBuschJ
            JaredBusch @Obsolesce
            last edited by

            @tim_g said in Install Nginx as a Reverse Proxy on Fedora 27:

            @jaredbusch said in Install Nginx as a Reverse Proxy on Fedora 27:

            @tim_g STFU already. No one fucking cares.

            Also get the fuck over yourself already.

            Aww, is someone pointing out some flaws / difference of opinion / misconceptions in something you like or prefer?

            Here's a guide for you:

            0_1524246626520_5e68a19a-f7d4-4d89-a211-fa9c4d9e225b-image.png

            No. I honestly don't' give a shit about the editors, that was the entire point of why the guide had the comment it had.
            But if you want to be a supremacist bitch about your editor of choice, feel free, just take it out of this thread.

            ObsolesceO 1 Reply Last reply Reply Quote 0
            • momurdaM
              momurda
              last edited by

              Jared where is your nginx.conf

              JaredBuschJ 1 Reply Last reply Reply Quote 0
              • ObsolesceO
                Obsolesce @JaredBusch
                last edited by

                @jaredbusch said in Install Nginx as a Reverse Proxy on Fedora 27:

                @tim_g said in Install Nginx as a Reverse Proxy on Fedora 27:

                @jaredbusch said in Install Nginx as a Reverse Proxy on Fedora 27:

                @tim_g STFU already. No one fucking cares.

                Also get the fuck over yourself already.

                Aww, is someone pointing out some flaws / difference of opinion / misconceptions in something you like or prefer?

                Here's a guide for you:

                0_1524246626520_5e68a19a-f7d4-4d89-a211-fa9c4d9e225b-image.png

                No. I honestly don't' give a shit about the editors, that was the entire point of why the guide had the comment it had.
                But if you want to be a supremacist bitch about your editor of choice, feel free, just take it out of this thread.

                Not supremacist, only correcting misconceptions that were mentioned... as you and Scott do all the time, in any thread they come up. If I do it, then I'm a "supremacist bitch"? Go piss up a rope and slip off.

                1 Reply Last reply Reply Quote 0
                • JaredBuschJ
                  JaredBusch @momurda
                  last edited by JaredBusch

                  @momurda said in Install Nginx as a Reverse Proxy on Fedora 27:

                  Jared where is your nginx.conf

                  I do not normally modify the default conf file

                  1 Reply Last reply Reply Quote 0
                  • EddieJenningsE
                    EddieJennings
                    last edited by

                    My experiment last night with Nginx worked. I'm going to see if I can replicate it tonight, and post the config for critique.

                    1 Reply Last reply Reply Quote 1
                    • momurdaM
                      momurda
                      last edited by

                      I am trying to copy this setup but using wildcard cert instead.
                      So, i have an http server setup with mediawiki. It has no https.
                      I have this nginx proxy setup so that the http site is redirected correctly.
                      edit:well it isnt doing http now either Not sure what i did, was working yesterday just fine.
                      However it wont seem to proxy https.
                      I think this is probably because my server.domain.conf in /etc/nginx/conf.d/server.domain.conf proxy_pass parameter is trying to redirect to https of this server which doesnt have https.
                      What to do in this type of situation?
                      I asked about this earlier in thread, seems it can work. Ive just messed something up.
                      I have not messed about with nginx.conf.
                      Not really sure how it can be used unmodified to proxy https as nothing is defined for https by default.

                      server.domain.conf file in /etc/nginx/conf.d/ :

                      server {
                              client_max_body_size 40M;
                              listen 443 ssl;
                              server_name server.domain.com;
                              ssl          on;
                              ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
                              ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
                      
                              location / {
                                      proxy_set_header X-Real-IP $remote_addr;
                                      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                      proxy_set_header Host $http_host;
                                      proxy_set_header X-NginX-Proxy true;
                                      proxy_pass https://10.1.0.247:443; # HERE IS ISSUE I THINK
                                      proxy_redirect off;
                              }
                      }
                      server {
                              client_max_body_size 40M;
                              listen 80;
                              server_name server.domain.com;
                      
                              location / {
                                      proxy_set_header X-Real-IP $remote_addr;
                                      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                      proxy_set_header Host $http_host;
                                      proxy_set_header X-NginX-Proxy true;
                                      proxy_pass http://10.1.0.247:80;
                                      proxy_redirect off;
                              }
                      }
                      
                      black3dynamiteB travisdh1T 2 Replies Last reply Reply Quote 0
                      • black3dynamiteB
                        black3dynamite @momurda
                        last edited by

                        @momurda said in Install Nginx as a Reverse Proxy on Fedora 27:

                        I am trying to copy this setup but using wildcard cert instead.
                        So, i have an http server setup with mediawiki. It has no https.
                        I have this nginx proxy setup so that the http site is redirected correctly.
                        edit:well it isnt doing http now either Not sure what i did, was working yesterday just fine.
                        However it wont seem to proxy https.
                        I think this is probably because my server.domain.conf in /etc/nginx/conf.d/server.domain.conf proxy_pass parameter is trying to redirect to https of this server which doesnt have https.
                        What to do in this type of situation?
                        I asked about this earlier in thread, seems it can work. Ive just messed something up.
                        I have not messed about with nginx.conf.
                        Not really sure how it can be used unmodified to proxy https as nothing is defined for https by default.

                        server.domain.conf file in /etc/nginx/conf.d/ :

                        server {
                                client_max_body_size 40M;
                                listen 443 ssl;
                                server_name server.domain.com;
                                ssl          on;
                                ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
                                ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
                        
                                location / {
                                        proxy_set_header X-Real-IP $remote_addr;
                                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                        proxy_set_header Host $http_host;
                                        proxy_set_header X-NginX-Proxy true;
                                        proxy_pass https://10.1.0.247:443; # HERE IS ISSUE I THINK
                                        proxy_redirect off;
                                }
                        }
                        server {
                                client_max_body_size 40M;
                                listen 80;
                                server_name server.domain.com;
                        
                                location / {
                                        proxy_set_header X-Real-IP $remote_addr;
                                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                        proxy_set_header Host $http_host;
                                        proxy_set_header X-NginX-Proxy true;
                                        proxy_pass http://10.1.0.247:80;
                                        proxy_redirect off;
                                }
                        }
                        

                        On your Mediawiki server, take a look at your LocalSettings.php file. What do you have set for $wgServer?

                        momurdaM 1 Reply Last reply Reply Quote 0
                        • momurdaM
                          momurda @black3dynamite
                          last edited by momurda

                          It is http://server.domain.com

                          Why did LE give me .pem files? edit: dont know

                          Why cant i convert these pem files to .crt and .key? edit: somehow all these .pem files now have 0 size which doesnt make sense. Worked fine yesterday.

                          openssl x509 -outform der -in cert.pem -out cert.crt
                          unable to load certificate
                          140515541610688:error:0906D06C:PEM routines:PEM_read_bio:no start line:../crypto/pem/pem_lib.c:691:Expecting: TRUSTED CERTIFICATE
                          
                          
                          ObsolesceO JaredBuschJ 2 Replies Last reply Reply Quote 0
                          • ObsolesceO
                            Obsolesce @momurda
                            last edited by

                            @momurda

                            What's the original cert that you have?

                            1 Reply Last reply Reply Quote 0
                            • JaredBuschJ
                              JaredBusch @momurda
                              last edited by

                              @momurda said in Install Nginx as a Reverse Proxy on Fedora 27:

                              It is http://server.domain.com

                              Why did LE give me .pem files? edit: dont know

                              Why cant i convert these pem files to .crt and .key? edit: somehow all these .pem files now have 0 size which doesnt make sense. Worked fine yesterday.

                              openssl x509 -outform der -in cert.pem -out cert.crt
                              unable to load certificate
                              140515541610688:error:0906D06C:PEM routines:PEM_read_bio:no start line:../crypto/pem/pem_lib.c:691:Expecting: TRUSTED CERTIFICATE
                              
                              

                              You are supposed to have .pem files, always. That tells you the encoding type of the key and certificate. If you did not know pem files mean you have a DER encoded certificate and key file.

                              1 Reply Last reply Reply Quote 0
                              • JaredBuschJ
                                JaredBusch
                                last edited by JaredBusch

                                @momurda I setup this server the day I made those instructions. Here is one of the conf files.

                                [jbusch@proxy ~]$ sudo cat /etc/nginx/conf.d/nextcloud.conf 
                                [sudo] password for jbusch: 
                                server {
                                    client_max_body_size 40M;
                                    server_name nc.jj.com;
                                    proxy_set_header X-Real-IP $remote_addr;
                                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                    proxy_set_header Host $http_host;
                                    proxy_set_header X-NginX-Proxy true;
                                    proxy_redirect off;
                                    location / {
                                        proxy_set_header X-Real-IP $remote_addr;
                                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                        proxy_set_header Host $http_host;
                                        proxy_set_header X-NginX-Proxy true;
                                        proxy_pass http://10.201.1.17;
                                        proxy_redirect off;
                                        # Socket.IO Support
                                        proxy_http_version 1.1;
                                        proxy_set_header Upgrade $http_upgrade;
                                        proxy_set_header Connection "upgrade";
                                    }
                                    ssl_stapling on;
                                    ssl_stapling_verify on;
                                #    ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
                                #    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
                                #    ssl_prefer_server_ciphers on;
                                    ssl_session_cache shared:SSL:10m;
                                    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
                                
                                    listen 443 ssl; # managed by Certbot
                                    ssl_certificate /etc/letsencrypt/live/nc.jj.com/fullchain.pem; # managed by Certbot
                                    ssl_certificate_key /etc/letsencrypt/live/nc.jj.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
                                
                                }
                                server {
                                    client_max_body_size 40M;
                                    listen 80;
                                    server_name nc.jj.com;
                                    rewrite        ^ https://$server_name$request_uri? permanent;
                                }
                                
                                wirestyle22W 1 Reply Last reply Reply Quote 2
                                • momurdaM
                                  momurda
                                  last edited by

                                  Ok i am on a short vacation starting now. Ill try getting this fixed up on Tuesday when i am back.

                                  1 Reply Last reply Reply Quote 0
                                  • wirestyle22W
                                    wirestyle22 @JaredBusch
                                    last edited by

                                    @jaredbusch take out the real domain

                                    JaredBuschJ 1 Reply Last reply Reply Quote 1
                                    • JaredBuschJ
                                      JaredBusch @wirestyle22
                                      last edited by

                                      @wirestyle22 said in Install Nginx as a Reverse Proxy on Fedora 27:

                                      @jaredbusch take out the real domain

                                      missed 1 of 4. /slacker

                                      1 Reply Last reply Reply Quote 2
                                      • travisdh1T
                                        travisdh1 @momurda
                                        last edited by

                                        @momurda said in Install Nginx as a Reverse Proxy on Fedora 27:

                                        I am trying to copy this setup but using wildcard cert instead.
                                        So, i have an http server setup with mediawiki. It has no https.
                                        I have this nginx proxy setup so that the http site is redirected correctly.
                                        edit:well it isnt doing http now either Not sure what i did, was working yesterday just fine.
                                        However it wont seem to proxy https.
                                        I think this is probably because my server.domain.conf in /etc/nginx/conf.d/server.domain.conf proxy_pass parameter is trying to redirect to https of this server which doesnt have https.
                                        What to do in this type of situation?
                                        I asked about this earlier in thread, seems it can work. Ive just messed something up.
                                        I have not messed about with nginx.conf.
                                        Not really sure how it can be used unmodified to proxy https as nothing is defined for https by default.

                                        server.domain.conf file in /etc/nginx/conf.d/ :

                                        server {
                                                client_max_body_size 40M;
                                                listen 443 ssl;
                                                server_name server.domain.com;
                                                ssl          on;
                                                ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
                                                ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
                                        
                                                location / {
                                                        proxy_set_header X-Real-IP $remote_addr;
                                                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                                        proxy_set_header Host $http_host;
                                                        proxy_set_header X-NginX-Proxy true;
                                                        proxy_pass https://10.1.0.247:443; # HERE IS ISSUE I THINK
                                                        proxy_redirect off;
                                                }
                                        }
                                        server {
                                                client_max_body_size 40M;
                                                listen 80;
                                                server_name server.domain.com;
                                        
                                                location / {
                                                        proxy_set_header X-Real-IP $remote_addr;
                                                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                                        proxy_set_header Host $http_host;
                                                        proxy_set_header X-NginX-Proxy true;
                                                        proxy_pass http://10.1.0.247:80;
                                                        proxy_redirect off;
                                                }
                                        }
                                        

                                        If you have a wildcard cert, could you put all the ssl settings into their own ssl.conf file? I won't have time to answer my own question till the middle of next week 😞

                                        1 Reply Last reply Reply Quote 0
                                        • EddieJenningsE
                                          EddieJennings
                                          last edited by EddieJennings

                                          This guide has worked perfectly for me -- great for learning as well, as I had a chance to take pieces and look them up.

                                          Just to make sure my thinking is right, tell me if this is what's happening if I try to reach my site using HTTP.

                                          URL for the example is http://testweb1.ejsllc.com

                                          1. Request gets to the reverseproxy.
                                          2. Request does not match the first server block, as it is specifically listening on port 443.
                                          3. Request does match the second server block since server_name matches and it's listening on port 80.
                                          4. The second server block rewrites the URL to use https.
                                          5. The reverse proxy now evaluates the request again, which is now written as https://testweb1.ejsllc.com.
                                          6. Since no port was specified in the request, reverse proxy assumes the port will be 443, which will match the first server block, which is specifically listening on 443 and matches the server_name.
                                          7. The reverse proxy unencrypts the request and follows theproxy_pass directive to send it to http://SERVER_IP.
                                          8. SERVER_IPis listening on port 80, receives the unencrypted request, processes it, and sends the response back to the reverse proxy.
                                          9. The reverse proxy encrypts the response and send its back to the original requester.
                                          JaredBuschJ wirestyle22W 2 Replies Last reply Reply Quote 3
                                          • JaredBuschJ
                                            JaredBusch @EddieJennings
                                            last edited by

                                            @eddiejennings Correct.

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 3 / 6
                                            • First post
                                              Last post