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

    Setting up Nginx on CentOS 7 as a reverse proxy

    IT Discussion
    centos 7 nginx reverse proxy setup how to
    13
    57
    23.6k
    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.
    • W
      wirestyle22 @zachary715
      last edited by wirestyle22

      @zachary715 said in Setting up Nginx on CentOS 7 as a reverse proxy:

      @wirestyle22 Share your resolution if you will. I was trying to install nginx on a server with wiki.js the other day and was running into the same error.

      That occurs if you don't create actual entries for the server in the config files. I definitely agree with @JaredBusch now that I have gone through the configs and mostly know whats going on. As far as I can see it there are two ways to config.

      One is editing /etc/nginx/nginx.conf. This is one huge config and you have to add your server entries all into it, which is what it is referring to when it tells you to add a server_name directive to your nginx configuration. Example of a server entry that you would put into the nginx.conf from JB's gude:

      server {
      	client_max_body_size 40M;
      	listen 443 ssl;
      	server_name www.domain.com domain.com;	#change to your domain name
      	ssl          on;
      	ssl_certificate /etc/ssl/cacert.pem;	#this needs to be the path to your certificate information
      	ssl_certificate_key /etc/ssl/privkey.pem;	#this needs to be the path to your certificate information
      
      	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.0.0.2:443;	#change to your internal server IP
      		proxy_redirect off;
      	}
      }
      

      Inside of this config you will see a line that tells you any .conf file contained within /etc/nginx/conf.d/ will be used en lieu of the main nginx config. Those config files are identical to what I list above. As JB said you would name them your subdomain/domain name. subdomain.domain.conf <---not .com

      It's definitely better to do it the way JB did with separate config files just from an organizational standpoint as he said above.

      Check your files and make sure this is the case.

      Thanks to @scottalanmiller for taking time with me to explain some nginx stuff last night. Definitely helped me a lot conceptually

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

        @jaredbusch said in Setting up Nginx on CentOS 7 as a reverse proxy:

        I run in standalone mode and edit the conf files myself

        I'm interested if you're willing to write something up on that. I think I mostly understand this, but clarification would be great.

        1 Reply Last reply Reply Quote 0
        • B
          brandon220
          last edited by

          Just an FYI - to get semanage to work on Fedora 27, I had to install policycoreutils-python-utils

          J 1 Reply Last reply Reply Quote 0
          • J
            JaredBusch @brandon220
            last edited by

            @brandon220 said in Setting up Nginx on CentOS 7 as a reverse proxy:

            Just an FYI - to get semanage to work on Fedora 27, I had to install policycoreutils-python-utils

            Yeah, I really need to write a new guide.

            1 Reply Last reply Reply Quote 0
            • A
              Alex Sage @wirestyle22
              last edited by Alex Sage

              @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

              As JB said you would name them your subdomain/domain name. subdomain.domain.conf <---not .com

              I name mine subdomain.domain.tld.conf

              J 1 Reply Last reply Reply Quote 0
              • J
                JaredBusch @Alex Sage
                last edited by

                @aaronstuder said in Setting up Nginx on CentOS 7 as a reverse proxy:

                @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                As JB said you would name them your subdomain/domain name. subdomain.domain.conf <---not .com

                I name mine subdomain.domain.tld.conf

                Yeah, mine are the full thing with a .conf at the end.

                daerma.com.conf
                obelisk.daerma.com.conf
                
                W 1 Reply Last reply Reply Quote 0
                • W
                  wirestyle22 @JaredBusch
                  last edited by wirestyle22

                  @jaredbusch said in Setting up Nginx on CentOS 7 as a reverse proxy:

                  @aaronstuder said in Setting up Nginx on CentOS 7 as a reverse proxy:

                  @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                  As JB said you would name them your subdomain/domain name. subdomain.domain.conf <---not .com

                  I name mine subdomain.domain.tld.conf

                  Yeah, mine are the full thing with a .conf at the end.

                  daerma.com.conf
                  obelisk.daerma.com.conf
                  

                  Yeah, when I was writing I typed in the actual web address accidentally.

                  nc.domain.com instead of nc.domain.conf or nc.domain.com.conf

                  D 1 Reply Last reply Reply Quote 0
                  • D
                    dbeato @wirestyle22
                    last edited by

                    @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                    @jaredbusch said in Setting up Nginx on CentOS 7 as a reverse proxy:

                    @aaronstuder said in Setting up Nginx on CentOS 7 as a reverse proxy:

                    @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                    As JB said you would name them your subdomain/domain name. subdomain.domain.conf <---not .com

                    I name mine subdomain.domain.tld.conf

                    Yeah, mine are the full thing with a .conf at the end.

                    daerma.com.conf
                    obelisk.daerma.com.conf
                    

                    Yeah, when I was writing I typed in the actual web address accidentally.

                    nc.domain.com instead of nc.domain.conf or nc.domain.com.conf

                    I did the same today, total facepalm.

                    J 1 Reply Last reply Reply Quote 1
                    • J
                      JaredBusch @dbeato
                      last edited by JaredBusch

                      @dbeato said in Setting up Nginx on CentOS 7 as a reverse proxy:

                      @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                      @jaredbusch said in Setting up Nginx on CentOS 7 as a reverse proxy:

                      @aaronstuder said in Setting up Nginx on CentOS 7 as a reverse proxy:

                      @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                      As JB said you would name them your subdomain/domain name. subdomain.domain.conf <---not .com

                      I name mine subdomain.domain.tld.conf

                      Yeah, mine are the full thing with a .conf at the end.

                      daerma.com.conf
                      obelisk.daerma.com.conf
                      

                      Yeah, when I was writing I typed in the actual web address accidentally.

                      nc.domain.com instead of nc.domain.conf or nc.domain.com.conf

                      I did the same today, total facepalm.

                      You can name them whatever you want. I just personally like this format.

                      D 1 Reply Last reply Reply Quote 0
                      • D
                        dbeato @JaredBusch
                        last edited by

                        @jaredbusch said in Setting up Nginx on CentOS 7 as a reverse proxy:

                        @dbeato said in Setting up Nginx on CentOS 7 as a reverse proxy:

                        @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                        @jaredbusch said in Setting up Nginx on CentOS 7 as a reverse proxy:

                        @aaronstuder said in Setting up Nginx on CentOS 7 as a reverse proxy:

                        @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                        As JB said you would name them your subdomain/domain name. subdomain.domain.conf <---not .com

                        I name mine subdomain.domain.tld.conf

                        Yeah, mine are the full thing with a .conf at the end.

                        daerma.com.conf
                        obelisk.daerma.com.conf
                        

                        Yeah, when I was writing I typed in the actual web address accidentally.

                        nc.domain.com instead of nc.domain.conf or nc.domain.com.conf

                        I did the same today, total facepalm.

                        You can name them whatever you want. I just personally like this format.

                        Well, yeah but the configuration looks for all *.conf files which failed on loading the site at first.

                        J 1 Reply Last reply Reply Quote 0
                        • J
                          JaredBusch @dbeato
                          last edited by

                          @dbeato said in Setting up Nginx on CentOS 7 as a reverse proxy:

                          @jaredbusch said in Setting up Nginx on CentOS 7 as a reverse proxy:

                          @dbeato said in Setting up Nginx on CentOS 7 as a reverse proxy:

                          @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                          @jaredbusch said in Setting up Nginx on CentOS 7 as a reverse proxy:

                          @aaronstuder said in Setting up Nginx on CentOS 7 as a reverse proxy:

                          @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                          As JB said you would name them your subdomain/domain name. subdomain.domain.conf <---not .com

                          I name mine subdomain.domain.tld.conf

                          Yeah, mine are the full thing with a .conf at the end.

                          daerma.com.conf
                          obelisk.daerma.com.conf
                          

                          Yeah, when I was writing I typed in the actual web address accidentally.

                          nc.domain.com instead of nc.domain.conf or nc.domain.com.conf

                          I did the same today, total facepalm.

                          You can name them whatever you want. I just personally like this format.

                          Well, yeah but the configuration looks for all *.conf files which failed on loading the site at first.

                          Right, you can name it wtf.conf if you want is what I mean.I just personally like the fqdn.conf structure, so that is how I wrote the guide.

                          D 1 Reply Last reply Reply Quote 1
                          • D
                            dbeato @JaredBusch
                            last edited by

                            @jaredbusch said in Setting up Nginx on CentOS 7 as a reverse proxy:

                            @dbeato said in Setting up Nginx on CentOS 7 as a reverse proxy:

                            @jaredbusch said in Setting up Nginx on CentOS 7 as a reverse proxy:

                            @dbeato said in Setting up Nginx on CentOS 7 as a reverse proxy:

                            @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                            @jaredbusch said in Setting up Nginx on CentOS 7 as a reverse proxy:

                            @aaronstuder said in Setting up Nginx on CentOS 7 as a reverse proxy:

                            @wirestyle22 said in Setting up Nginx on CentOS 7 as a reverse proxy:

                            As JB said you would name them your subdomain/domain name. subdomain.domain.conf <---not .com

                            I name mine subdomain.domain.tld.conf

                            Yeah, mine are the full thing with a .conf at the end.

                            daerma.com.conf
                            obelisk.daerma.com.conf
                            

                            Yeah, when I was writing I typed in the actual web address accidentally.

                            nc.domain.com instead of nc.domain.conf or nc.domain.com.conf

                            I did the same today, total facepalm.

                            You can name them whatever you want. I just personally like this format.

                            Well, yeah but the configuration looks for all *.conf files which failed on loading the site at first.

                            Right, you can name it wtf.conf if you want is what I mean.I just personally like the fqdn.conf structure, so that is how I wrote the guide.

                            The guide was awesome and worked perfectly.

                            1 Reply Last reply Reply Quote 3
                            • Z
                              zenbu @JaredBusch
                              last edited by

                              @JaredBusch I setup a reverse proxy with nginx for ScreenConnect, but the relay port isn't working. Can you provide your setup for how your relay is setup? Does it require two different IPs?

                              F scottalanmillerS 2 Replies Last reply Reply Quote 0
                              • F
                                flaxking @zenbu
                                last edited by

                                @zenbu said in Setting up Nginx on CentOS 7 as a reverse proxy:

                                @JaredBusch I setup a reverse proxy with nginx for ScreenConnect, but the relay port isn't working. Can you provide your setup for how your relay is setup? Does it require two different IPs?

                                That's not HTTP traffic. You would have to set Nginx up for TCP/UDP load balancing

                                Z 1 Reply Last reply Reply Quote 1
                                • scottalanmillerS
                                  scottalanmiller @zenbu
                                  last edited by

                                  @zenbu said in Setting up Nginx on CentOS 7 as a reverse proxy:

                                  @JaredBusch I setup a reverse proxy with nginx for ScreenConnect, but the relay port isn't working. Can you provide your setup for how your relay is setup? Does it require two different IPs?

                                  First, do you need a revere proxy for that? It's not web traffic. If you do, I'd recommend HA-Proxy.

                                  Second, don't use CentOS 7 today. This guide is very old.

                                  J 2 Replies Last reply Reply Quote 0
                                  • J
                                    JaredBusch @scottalanmiller
                                    last edited by JaredBusch

                                    @scottalanmiller said in Setting up Nginx on CentOS 7 as a reverse proxy:

                                    @zenbu said in Setting up Nginx on CentOS 7 as a reverse proxy:

                                    @JaredBusch I setup a reverse proxy with nginx for ScreenConnect, but the relay port isn't working. Can you provide your setup for how your relay is setup? Does it require two different IPs?

                                    First, do you need a revere proxy for that? It's not web traffic. If you do, I'd recommend HA-Proxy.

                                    Right, you port forward the relay traffic. It is encrypted by the clients on each end. You SSL certificates do not apply to it anyway.

                                    1 Reply Last reply Reply Quote 0
                                    • J
                                      JaredBusch @scottalanmiller
                                      last edited by

                                      @scottalanmiller said in Setting up Nginx on CentOS 7 as a reverse proxy:

                                      Second, don't use CentOS 7 today. This guide is very old.

                                      Well the new guide is old already too. But at least it is still the same on Fedora 31 as it was on Fedora 27...

                                      https://www.mangolassi.it/topic/16651/install-nginx-as-a-reverse-proxy-on-fedora-27

                                      1 Reply Last reply Reply Quote 3
                                      • Z
                                        zenbu @flaxking
                                        last edited by

                                        @flaxking Good point, I found out about that and have been reading up on it. Using ngx_stream_ssl_preread_module seems like it may be the solution. It will let you differentiate between HTTP SSL traffics and non HTTP ssl traffic. That way I'm hoping to use port 443 for both the web portal and the ScreenConnect relay.

                                        scottalanmillerS 2 Replies Last reply Reply Quote 0
                                        • scottalanmillerS
                                          scottalanmiller @zenbu
                                          last edited by

                                          @zenbu said in Setting up Nginx on CentOS 7 as a reverse proxy:

                                          That way I'm hoping to use port 443 for both the web portal and the ScreenConnect relay.

                                          I don't believe that there is any possible way to do that. Because you'd need a host header or something to differentiate and SC doesn't work that way.

                                          The traffic is designed to be on different ports. They can be any ports that you want, but not the same one.

                                          1 Reply Last reply Reply Quote 0
                                          • scottalanmillerS
                                            scottalanmiller @zenbu
                                            last edited by

                                            @zenbu

                                            You have two issues... the first is what we call "being weird." This is a bizarre thing to be trying to do. It's not wrong, it's just "weird"... that kind of thing that hard to describe but it's clearly strange and trying to invent a wheel that already works really well.

                                            The second issue is your goal: what goal are you trying to accomplish by doing this? There's not normally any reason to have the proxy of the SC control port traffic. What problem are you trying to solve by doing this?

                                            J 1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 3 / 3
                                            • First post
                                              Last post