let's say i have two domain names: one.com and two.com.
There is also a project in PHP that is hosted on the server (NGINX) and is available via the following links. http://my.server.com/ ** one * / and http://my.server.com/ ** two * /.
How can I make it so that when a client in the browser asked one.com , it showed content from http://my.server.com/ one /, and when two.com , it showed content from http: //my.server .com / two / while in the address of the browser continued to show one.com or two.com, respectively?
How to do this with nginx?
Thank you in advance.
#user nobody; worker_processes auto; worker_rlimit_nofile 2048; error_log /var/log/nginx/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 2048; } http { server_tokens off; include mime.types; default_type application/octet-stream; log_format main '$http_x_forwarded_for - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; # Websocket support #upstream websocket { # server 127.0.0.1:<PORT>; #} server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; include /etc/nginx/aliases.conf; #location /ws { # proxy_pass http://websocket; # proxy_http_version 1.1; # proxy_set_header Upgrade $http_upgrade; # proxy_set_header Connection "Upgrade"; #} location / { root /var/www/webroot/ROOT; index index.html index.htm index.php; location ~ \.php$ { location ~ /\. { deny all; access_log off; log_not_found off; } include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; fastcgi_param PATH_INFO $fastcgi_script_name; } } index index.php index.html index.htm; #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} location ~ /\. { deny all; access_log off; log_not_found off; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} location ~ \.php$ { location ~ /\. { deny all; access_log off; log_not_found off; } include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /var/www/webroot$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param DOCUMENT_ROOT /var/www/webroot; } } include /etc/nginx/conf.d/*.conf; }
server {...}sectionserver {...}, so that you do not need to describe all possible configuration options. - aleksandr barakin