Welcome! Log In Create A New Profile


Access NGINX from outside with another port

Posted by Gurken2108 
Access NGINX from outside with another port
September 15, 2016 06:04PM
Hello together,

I want to keep the ServerName and Port dynamicly on my rewrite: Lets say the Firewall redirect port 8081 to 80. So, if i access the webserver for example with "" or "my.domain.tld:8081/frontend" i should be redirect to "" or "my.domain.tld:8081/frontend/"

If i use the normal redirect rewrite ^(.*[^/])$ $1/ permanent; and i access with the port 8081 the port got removed. (I already tried port_in_redirect

When i acces with "my.domain.tld:8081/frontend" (without slash at the end) i got rewritten to port 80, but port 80 is not open in the firewall, and if i access with the slash at the end everthing works. So somewhere nginx removes the port. And yes, this is the server because i got a new entry in the access.log.

I use almost the default configuration:
server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;

server_name _;
rewrite ^(.*[^/])$ $1/ permanent;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;

Thank you in anticipation!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 104
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