Cluster - How to configure nginx to be accessible by IP and domain name
过去多啦不再A梦
过去多啦不再A梦 2017-05-16 17:09:10
0
2
897

I used nginx to build a cluster and deployed it on the telecommunications cloud. The external network uses IP access, 192.100.xxx.xxx:8080/jess, and a domain name to access www.xxx.net/jess. The domain name is The bureau mapped it by itself.

Make it yourself. There is no problem with IP access. If you access it with a domain name, the homepage can be opened. After logging in, all requests return IP. How to configure it so that IP access returns IP and domain name access returns domain name. Post my nginx configuration

It’s my first time to use nginx. I found some information but it’s not what I want. I hope I can ask an expert to teach me, or where can I find information that explains the configuration of nginx in detail. Thanks in advance

 #负载均衡配置
     upstream tomcat_server {
          server 192.168.156.1:8090 max_fails=3 weight=1 fail_timeout=60s;
          server 192.168.156.2:8080 max_fails=3 weight=3 fail_timeout=60s;
       }
    server {
        listen 8080;
        server_name  localhost,;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
            index    index.jsp;
            proxy_pass  http://tomcat_server;
            proxy_set_header Host $host:$server_port;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
过去多啦不再A梦
过去多啦不再A梦

reply all(2)
迷茫

If the backend jumps through 30x, you can use:

proxy_redirect http://192.100.xxx.xxx/ /;

To replace the Location in the response header. If the page jumps using javascript, you may need to modify the back-end code. If it cannot be modified, you can use nginx replacement modules such as sub_filter.
Reference https://www.centos.bz/2014/06...

洪涛

Looking for answers, but still haven’t found a solution

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template