Answer the question
In order to leave comments, you need to log in
How to make different location based on IP?
There is a simple nginx config:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name mydomain.ru;
root /home/user/www;
index index.html index.php;
access_log /var/log/nginx/site.access.log main;
error_log /var/log/nginx/site.error.log main;
location / {
root /home/user/www;
index index.html index.php;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php;
}
}
include templates/ssl;
include templates/php7.2;
include templates/static;
include templates/gzip;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name mydomain.ru;
root /home/user/www;
index index.html index.php;
access_log /var/log/nginx/site.access.log main;
error_log /var/log/nginx/site.error.log main;
if ($remote_addr != 127.0.0.1) {
location / {
proxy_pass http://localhost:3000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
} else {
location / {
root /home/user/www;
index index.html index.php;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php;
}
}
}
include templates/ssl;
include templates/php7.2;
include templates/static;
include templates/gzip;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question