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

    302 Moved Error

    IT Discussion
    nginx web reverse proxy
    3
    12
    1.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.
    • E
      Emsanator
      last edited by Emsanator

      0_1522870340806_Sun1.jpg

      I have 2 VM for a Nextcloud and publishing my internet sites. These two servers are connected with ProxyPass.

      (vhost.conf for 192.168.1.2)

      <VirtualHost 192.168.1.7:8181>
      ServerName domain.com
      ServerAlias www.domain.com
      ServerAdmin [email protected]
      DocumentRoot /home/username/public_html/
      UseCanonicalName Off
      ScriptAlias /cgi-bin/ /home/username/public_html/_SubDomains/domain/cgi-bin/
      
      # Custom settings are loaded below this line (if any exist)
      # Include "/usr/local/apache/conf/userdata/username/domain.com/*.conf
      
      <IfModule mod_userdir.c>
      	UserDir disabled
      	UserDir enabled username
      </IfModule>
      
      <IfModule mod_suexec.c>
      	SuexecUserGroup username username
      </IfModule>
      
      <IfModule mod_suphp.c>
      	suPHP_UserGroup username username
      	suPHP_ConfigPath /home/username
      </IfModule>
      
      ProxyPass / http://192.168.1.7/
      ProxyPassReverse / http://192.168.1.7/
      
       </VirtualHost>
      

      Nginx:

      # Virtual host file starts here
      
      server {
      listen 192.168.1.2:443;
      access_log /var/log/nginx/access.domain.com.log;
      error_log /var/log/nginx/error.domain.com.log;
      server_name domain.com www.domain.com;
      root /home/domain/public_html;
      
      ssl                  on;
      ssl_certificate      /etc/pki/tls/certs/domain.com.bundle;
      ssl_certificate_key  /etc/pki/tls/private/domain.com.key;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
      ssl_prefer_server_ciphers   on;
      
      ssl_session_cache   shared:SSL:20m;
      ssl_session_timeout 60m;
      
      add_header Strict-Transport-Security "max-age=31536000";
      add_header X-Content-Type-Options nosniff;
      
      location / {
      location ~.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|woff|ttf|svg|eot|sh)\$ {
      expires 7d; #Comment this out if you are using the apache backend cache-control/expires headers.
      try_files \$uri \@backend;
      }
      error_page 405 = \@backend;
      error_page 500 = \@custom;
      add_header X-Cache "HIT from Backend";
      proxy_pass http://192.168.1.2:8181;
      include proxy.inc;
      }
      location \@backend {
      internal;
      proxy_pass http://192.168.1.2:8181;
      include proxy.inc;
      }
      location \@custom {
      internal;
      proxy_pass http://192.168.1.2:8181;
      include proxy.inc;
      }
      location ~ .*\.(php|jsp|cgi|pl|py)?\$ {
      proxy_pass http://192.168.1.2:8181;
      include proxy.inc;
      }
      location ~ /\.ht {
      deny all;
      }
      }
      
      # Virtual host file ends here
      

      I am getting this error while loading the file:

          PUT            XHR              https://domain.com/@custom           [HTTP/1.1 302 Moved Temporarily 0ms]
      

      There's only trouble adding files. Display, delete actions are no problem.

      What could be the reason for this?
      Also, no problem if I use the local IP address.
      Thank you.

      1 Reply Last reply Reply Quote 1
      • scottalanmillerS
        scottalanmiller
        last edited by

        That's an Apache config, not an Nginx config.

        E 1 Reply Last reply Reply Quote 0
        • E
          Emsanator @scottalanmiller
          last edited by

          @scottalanmiller

          I have update my question.

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

            I'm going to guess that this is not a common issue, as this thread already comes up nearly at the top of search results about this.

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

              So if you bypass the Nginx reverse proxy, does the site work normally on the LAN?

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

                What is the reason for your massively complicated reverse proxy configuration? That's nothing like what I use for Nextcloud.

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

                  I'm especially curious as to the intention of this section:

                  location \@backend {
                  internal;
                  proxy_pass http://192.168.1.2:8181;
                  include proxy.inc;
                  }
                  location \@custom {
                  internal;
                  proxy_pass http://192.168.1.2:8181;
                  include proxy.inc;
                  }
                  location ~ .*\.(php|jsp|cgi|pl|py)?\$ {
                  proxy_pass http://192.168.1.2:8181;
                  include proxy.inc;
                  }
                  location ~ /\.ht {
                  deny all;
                  }
                  
                  1 Reply Last reply Reply Quote 0
                  • E
                    Emsanator @scottalanmiller
                    last edited by

                    @scottalanmiller said in 302 Moved Error:

                    So if you bypass the Nginx reverse proxy, does the site work normally on the LAN?

                    Yes, If I directly access the server [ 192.168.1.7 ], There is nothing problem.

                    @scottalanmiller said in 302 Moved Error:

                    I'm especially curious as to the intention of this section:

                    location \@backend {
                    internal;
                    proxy_pass http://192.168.1.2:8181;
                    include proxy.inc;
                    }
                    location \@custom {
                    internal;
                    proxy_pass http://192.168.1.2:8181;
                    include proxy.inc;
                    }
                    location ~ .*\.(php|jsp|cgi|pl|py)?\$ {
                    proxy_pass http://192.168.1.2:8181;
                    include proxy.inc;
                    }
                    location ~ /\.ht {
                    deny all;
                    }
                    

                    I did not create this part, this is an automatically generated.

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

                      @emsanator said in 302 Moved Error:

                      I did not create this part, this is an automatically generated.

                      What auto-generated that? I'm a little confused as to your setup.

                      Generally you run NextCloud on Apache, that's the application server. Then if you want a reverse proxy, which most of us do, Nginx is perfect for this. But nothing on the Nginx would be auto-generated as it would not talk to the NextCloud box directly.

                      I think you might have layers of proxies here or something.

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

                        @scottalanmiller said in 302 Moved Error:

                        I think you might have layers of proxies here or something.

                        He has a disaster here.

                        Nothing is normal.

                        Also, if I followed the IP scheme right, he has the following:

                        Nextcloud running under Nginx and not Apache on: 192.168.1.7 This a non standard deployment. Not that it can be bad, but it is non standard.

                        Nginx and Apache running on 192.168.1.2. Again this is not what I would consider a standard way to deploy something like this. People do this all the time, but when you are in a VM environment, I prefer to use single task VMs.

                        Now he has Apache for publishing his internet sites on 192.168.1.2. fine.

                        He build Nextcloud on 192.168.1.7 Fine.

                        On to the vhost file on 192.168.1.2. Well this file is showing that it is listening on 192.168.1.7:8181. Well that is not possible as that IP is not on that box. 192.168.1.2 is the only system with Apache, so this has to be where the vhost file is as Nginx does not have vhost files.

                        So you either posted something wrong or you have totally hosed this entire thing up.

                        But let's continue.

                        The posted Nginx config file (incorrectly called a virtual host file also) contians a single server block listing on 192.168.1.2:443 only. It also only has forwarding posted that forward to 192.168.1.2:8181

                        So nothing is ever getting proxied to the nextcloud system.

                        Also port 8181 is not in the default list of ports the SELinux allowed to be used by HTTP,

                        Additionally, both config files are showing that the document roots are in subfolders of /home/username/. By default these locations will not have the proper permissions (user/group) or security contexts (SELinux) to be executed.

                        Finally, as insinuated by @scottalanmiller, there is no default auto generating tool for Nginx Server blocks.

                        In conclusion, as posted, this configuration will never do ANYTHING as Nginx is listening on 443 and sending to apache port 8181, yet there is no apache instance listening on port 8181.

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

                          @scottalanmiller said in 302 Moved Error:

                          @emsanator said in 302 Moved Error:

                          I did not create this part, this is an automatically generated.

                          What auto-generated that? I'm a little confused as to your setup.

                          Generally you run NextCloud on Apache, that's the application server. Then if you want a reverse proxy, which most of us do, Nginx is perfect for this. But nothing on the Nginx would be auto-generated as it would not talk to the NextCloud box directly.

                          That auto generated stuff is only sending stuff to the Apache host on the same box as Nginx.

                          1 Reply Last reply Reply Quote 0
                          • E
                            Emsanator
                            last edited by

                            @jaredbusch said in 302 Moved Error:

                            That auto generated stuff is only sending stuff to the Apache host on the same box as Nginx.

                            Thanks for your valuable comments.

                            I solved this problem.
                            I've erased all routing on Nginx/Apache :smiling_face_with_smiling_eyes: ,

                            I created a virtual server for HAproxy, I installed HAproxy and currently all virtual servers routing process was completed.

                            Only I have one problem with HAproxy conf. file, I do not know how to do FTP Routing.
                            if you want to see the topic, please visit this topic.

                            1 Reply Last reply Reply Quote 0
                            • 1 / 1
                            • First post
                              Last post