将子域映射到在路径

时间:2017-05-03 12:55:20

标签: nginx amazon-ec2 proxy tomcat7 reverse-proxy

我在同一端口(8080)上的同一个ec2实例上运行了3个应用程序(一个Web应用程序,2个角度应用程序) 应用的路径是

  1. http://53.233.23.12:8080/Abc
  2. http://53.233.23.12:8080/Xyz
  3. http://53.233.23.12:8080/Pqr
  4. 我在服务器中使用Nginx进行重定向 我的nginx.conf文件看起来像这个`

    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /var/run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/nginx/README.dynamic.
       include /usr/share/nginx/modules/*.conf;
    
    events {
            worker_connections 1024;
          }
    http{
           log_format  main  '$remote_addr - $remote_user [$time_local] 
        "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    
    access_log  /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    
    include /etc/nginx/conf.d/*.conf;
    
    index   index.html index.htm;
    
    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        include /etc/nginx/default.d/*.conf;
        server_name www.listmydebt.com listmydebt.com;
        return 301  http://listmydebt.com:8080/Abc;
    
    
        # redirect server error pages to the static page /40x.html
        error_page 404 /404.html;
            location = /40x.html {
        }
    
        # redirect server error pages to the static page /50x.html
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    
     }
        server {
            listen 80;
            server_name admin.listmydebt.com;
            return 301  http://listmydebt.com:8080/Xyz;
        }
         server {
            listen 80;
            server_name partner.listmydebt.com;
            return 301  http://listmydebt.com:8080/Pqr;
        }
      }
    

    指向同一IP地址(53.233.23.12)的所有域和子域(listmydebt.com,admin.listmydebt.com,partner.listmydebt.com)。 我的Nginx在端口80和tomcat服务器上运行,我的应用程序在端口8080上运行,

    当我将listmydebt.com重定向到http://listmydebt.com:8080/Abc并且浏览器网址已更改(http://listmydebt.com:8080/Abc)时。但我想要的是浏览器上的url应该与listmydebt.com保持一致,但它应该显示重定向的url content.same也会发生子域名。

    请帮帮我。如果需要任何其他信息,请提及。谢谢。

0 个答案:

没有答案