nginx being redirect to localhost

Viewed 143

I am facing an issue to config NGINX in a instance of EC2.

Currently I have two URL:

http://myserver.com -> shows the home page http://myserver.com/admin -> shows an admin console

The problem is that when I tried to access the Home Page, it redirects me to the localhost in my machine, but when I try the admin it works well.

This is my /etc/nginx/conf.d/default.conf

server {
    listen       80;
    listen       [::]:80;

    server_name my.compute.amazonaws.com my.compute.amazonaws.com;
    root  /var/www/pro/public;

    index index.php;

    gzip on;
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_vary on;

    location / {
# try to serve file directly, fallback to index.php
        try_files $uri /index.php$is_args$args;
    }


    location ~ ^/(index|index_dev|config|install)\.php(/|$) {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;
        fastcgi_buffers 64 64k;
        fastcgi_buffer_size 128k;
    }

    location ~* ^[^(\.php)]+\.(jpg|jpeg|gif|png|ico|css|pdf|ppt|txt|bmp|rtf|js)$ {
        access_log off;
        expires 1h;
        add_header Cache-Control public;
    }
 error_log /var/log/nginx/localhost_error.log;
    access_log /var/log/nginx/localhost_access.log;
}

and this is the /etc/nginx/nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/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            off;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
}

I already tried things like but no success

proxy_redirect off;
proxy_set_header Host $http_host;

Does someone have a clue about that? Thanks for the help

0 Answers
Related