D
D
distmemory2019-06-25 12:44:46
Nginx
distmemory, 2019-06-25 12:44:46

How to add admin settings to this config?

Now the application itself is running on the server using xxx.xxx.xxx.xxx ip on local port 5000, you need to make sure that the admin panel works on the same ip. I would like to make an appeal to it like xxx.xxx.xxx.xxx/admin. I found a close answer in another question, but I can’t apply it to my task, I’m confused because of the @fallback block. Here is the code of the person who gave the approximate answer:

server {
listen 80;
server_name site.ru;

location /admin {
    proxy_pass http://localhost:50001;
}

location / {
    proxy_pass http://localhost:50000;
}
}

And my config:
server {
server_name xxx.xxx.xxx.xxx;
charset off;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/site.org/*.conf;
access_log /var/www/httpd-logs/site.org.access.log;
error_log /var/www/httpd-logs/site.org.error.log notice;
ssi on;
set $root_path /var/www/www-root/data/www/site.org;
root $root_path;
location / {
    location ~ [^/]\.ph(p\d*|tml)$ {
        try_files /does_not_exists @fallback;
    }
    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
        try_files $uri $uri/ @fallback;
    }
    location / {
        try_files /does_not_exists @fallback;
    }
}
location @fallback {
    proxy_pass http://127.0.0.1:5000;
    proxy_redirect http://127.0.0.1:5000 /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Port $server_port;
    access_log off;
}
listen xxx.xxx.xxx.xxx:80 default_server;
}

How to add the config and where to put the folder with the admin panel?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Syomov, 2019-06-25
@distmemory

Subject to explanation, you can simply insert location:

location /admin {
    proxy_pass http://localhost:50001;
}

below location / {}, replacing the port with the desired one. The only problem will be that your admin panel can correctly build its links inside, relative to /admin, and not relative to /. Perhaps it will have to be redone for this, perhaps such an opportunity is already in its configuration.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question