Welcome! Log In Create A New Profile

Advanced

nginx always rederict me to my internal ip

Posted by silb 
nginx always rederict me to my internal ip
November 25, 2014 09:41AM
Hello everybody,

im using nginx with owncloud on my raspberry pi. Under "sites available -> default" i've set it up like this.

server {
listen 80;
server_name 192.168.1.114;
return 301 https://$server_name$request_uri; # enforce https
}

server {
listen 443 ssl;
server_name 192.168.1.114;

ssl_certificate /etc/nginx/cert.pem;
ssl_certificate_key /etc/nginx/cert.key;

# Path to the root of your installation
root /var/www/owncloud;

......


Now, i've registered a no-ip domain, forwarded the ports etc. that i can access my cloud from anywhere.

I've changed the "server_name" to my no-ip domain and restarted nginx. Now when i type in "mynoipdomain.whatever.com" in my browser, it always rederict me to "192.168.1.114". Therefore im not able to access it over the internet.

What do i have to do that i can access my server from the internal ip when im in LAN (that it sync the files faster), but i also want to get access to it over my no-ip domain.

Any ideas?



Edited 2 time(s). Last edit at 11/25/2014 09:42AM by silb.
Re: nginx always rederict me to my internal ip
November 26, 2014 06:45AM
any ideas? :/
Re: nginx always rederict me to my internal ip
November 28, 2014 02:59AM
anyone? Im running out of nerves :(
Re: nginx always rederict me to my internal ip
November 28, 2014 03:54AM
Why not read the documentation: http://nginx.org/en/docs/http/server_names.html

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: nginx always rederict me to my internal ip
November 28, 2014 04:44AM
i've read it multiple times. When i put "noipdomain.org" as server_name it doesn't change anything. (Yes, i restarted nginx with sudo /etc/init.d/nginx restart). I can also put "blablabla" as server_name and i still got the behaviour i described above.

Here again my config Files.

nginx.conf
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

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

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##

#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;

##
# Virtual Host Configs
##


include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}


#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}



sites available -> default
When i change the server_name and restart nginx, i've got the same behaviour

upstream php-handler {
server 127.0.0.1:9000;
#server unix:/var/run/php5-fpm.sock;
}


server {
listen 80;
server_name blub;
return 301 https://blub$request_uri; # enforce https
}


server {
listen 443 ssl;
server_name blub;

ssl_certificate /etc/nginx/cert.pem;
ssl_certificate_key /etc/nginx/cert.key;

# Path to the root of your installation
root /var/www/owncloud;

client_max_body_size 7000M; # set max upload size
fastcgi_buffers 256 4k;
fastcgi_connect_timeout 6000;
fastcgi_send_timeout 18000;
fastcgi_read_timeout 18000;

rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {
deny all;
}

location / {
# The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;

rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;

try_files $uri $uri/ index.php;
}

location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass php-handler;

}

# Optional: set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
# Optional: Don't log access to assets
access_log off;
}

}



Edited 1 time(s). Last edit at 11/28/2014 04:49AM by silb.
Re: nginx always rederict me to my internal ip
November 28, 2014 07:18AM
When you access bla.com a DNS (which is usually your ISP dns) will convert bla.com into whatever the DNS points to, it does not matter where you are. Unless you make an internal DNS entry for example in etc/hosts making it point to some other IP address.

The question is what IP are you getting when your outside with ping bla.com and what IP when your at home.

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 158
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready