Answer the question
In order to leave comments, you need to log in
How to properly configure nginx reverse proxy - docker nginx?
There is a server, it costs nginx to distribute requests, there are also two containers, one of them must accept requests from ex1.example.com, the second from ex2.example.com (to the main site) and ap.ex2.example.com (site admin panel).
server {
listen 80;
server_name ex1.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443;
server_name ex1.example.com;
ssl_certificate /etc/letsencrypt/live/ex1.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ex1.example.com/privkey.pem;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/ex1.access.log;
location / {
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-Proto $scheme;
proxy_pass http://ex1.example.loc:8081;
proxy_read_timeout 90;
}
}
server {
charset utf-8;
index index.php;
listen 80;
server_name ex1.example.loc;
error_log /var/log/nginx/ex1.example.loc/error.log;
access_log /var/log/nginx/ex1.example.loc/access.log;
root /var/www/ex1.example.loc;
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php;
}
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
127.0.0.1 ex1.example.loc
Answer the question
In order to leave comments, you need to log in
Everything turned out to be much simpler, the nginx config was named ex2.example.com, of course, it didn’t pick it up automatically, renamed it to default.conf and everything flew ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question