Category Archives: backend

Because my virtual host does not seem to work [on hold]

I had never made a virtual host and made the following code

 <VirtualHost *:80>
ServerName mivhost.com 
ServerAlias www.mivhost.com
ServerAdmin [email protected]
DocumentRoot "htdocs/public"
<Directory htdocs/public>
Options FollowSymlinks
AllowOverride All
Require all granted
RewriteEngine on
RewriteRule "^([a-zA-Z0-9]*)$" "index.php?controlador=$1"  
LogLevel info
ErrorLog "htdocs/error.log"
CustomLog "htdocs/access.log" common
</Directory>

But it does not work for me because I was reading the rewriteEngine i could be put inside the virtualhost including the directories but it does not work another thing happens to me that by including this in bitnami-apps-vhosts.conf apache web server does not start me I'm sorry, I do not know English

Converting .htaccess to web.config for Running the code on Plesk Panel. Is it because of .htaccess , I am not able to run the code?

I have purchased a code from some website for having a social networking app on android. The server part of this app needs to be installed on the backend. After constant conversations with the developer , I was able to conclude that the .htaccess file is not able to process the commands because I am a Plesk Panel user and not a Cpanel User. The Service provider asked me to put the "web.config" Instead of ".htaccess" to perform the task. But I don't have any idea of how to convert/translate the code for this task. here is the code that needs to be converted into web.config format.

    #SetEnv APPLICATION_ENV development

DirectoryIndex /public/index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) $1 [L]
RewriteCond %{DOCUMENT_ROOT}/public%{REQUEST_URI} -f
RewriteRule ^(.+) /public/$1 [L]

Options +FollowSymLinks
RewriteEngine on 



RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /public/index.php?q=$1 [L,QSA]

#RewriteRule !\.(js|ico|gif|jpg|png|css|xml|xslt)$ /public/index.php

PS : The mod_rewrite is enabled

How does PHP set HTTP headers with the header() function?

I am learning HTTP and web programming and I was surprised to find out that you can set HTTP headers using php. I thought PHP was used to generate dynamic HTML web pages and create applications. It seems strange to me that PHP can set headers that are sent by the web server (e.g. Apache). I know PHP interpreter reads the PHP file and generates an output usually in the form of HTML.

Does this process work with pipes? In my opinion the apache server has to be able to receive commands from the PHP interpreter or it has to be able to interpret PHP functions itself. They are separate processes I think.

What mechanism is used by PHP to set headers to the web server application (httpd or Apache or something else)

Do all web servers support receiving and setting headers that are received via PHP?

Is it possible to set HTTP headers with all backend languages?

I searched through the website and I did not find an aswer to my question.

More specifically I want to know what command can apache or other web server send to PHP.exe application or PHP-CGI.exe application to receive other information besides the outputted HTML file.

nginx proxy_pass backend server traffic

I run the following configuration for an image-host. While everything works fine there is a lot of traffic between server 2 and 3 which I don't think there has to be. It seems server 2 is downloading data from server 3 while at the same time server 3 is also directly serving the image to the client... so why is server 2 requesting data from server 3?

50% of the total outgoing traffic on server 3 is incoming traffic on server 2.

If one requests a php file which has the following image embedded: http://example.com/upload/i/2014/12345.jpg it goes through the proxy pass, apache handles the php file and rewrites the image link which the nginx server on server 2 processes.

If one requests a php file with the the following image embedded: http://example.com/upload/i/2015/12345.jpg it goes through the proxy pass, apache handles the php file and rewrites the image link which the nginx server on server 3 processes BUT the data is being send to server 2 as well causing a massive influx of incoming traffic there. My question is why does this happen and can I somehow prevent this?

The same thing happens if I remove the apache rewrite rules and change it to nginx rewrite rules on server 1.

Server 1 (nginx)

server {
        server_name example.com;

        location / {
                proxy_pass                  http://1.2.3.4:21211;
                proxy_set_header            X-Real-IP  $remote_addr;
                proxy_set_header            Host "example.com";
                proxy_buffer_size           128k;
                proxy_buffers               4 256k;
                proxy_busy_buffers_size     256k;
        }
}

Server 2 (apache / nginx)

<VirtualHost *:21211>
        ServerName example.com

        DocumentRoot /storage/example.com/public

        <Directory /storage/example.com/public>
                Options -Indexes +FollowSymLinks
        </Directory>

        <Directory "/upload">
                RewriteEngine On
                RewriteRule ^i/2014/([0-9]{5}\.jpg)$ http://fs1.example.com/2014/$1  [R]
                RewriteRule ^i/2015/([0-9]{5}\.jpg)$ http://fs2.example.com/2015/$1  [R]
        </Directory>

</VirtualHost>

--

server {
        listen 80;
        server_name fs1.example.com;

        access_log off;
        error_log /dev/null;

        root /storage/fs1.example.com/upload;
}

Server 3 (nginx)

server {
        listen 80;
        server_name fs2.example.com;

        access_log off;
        error_log /dev/null;

        root /storage/fs2.example.com/upload;
}

Securing apache server for mobile app backend

I am new to backend development and security. I have a LAMP stack setup on AWS and have a Android application with can POST and GET messages to this server. I want to now make the server more secure.

Currently I have no security in place and have no idea where to start. I tried implementing SSL with Apache but didn't have much luck.

Any links to tutorials or reading or any other help will be appreciated.

Laravel 4 separate admin driectory htpasswd

I use Laravel 4, and I like to separate the admin area, to a different folder. I wnat this separation by phosocally, not only by filters, and route tricks. But I don't want to deal with two different laravel installation.

I already use different views, contorrels, and modells for the admin area, but I lik to use htpasswd protected folder as well, witch protects the admin page.

Can someone suggest me a way to do this?

Thanks!

How do I accurately measure a server’s 99th and 95th percentile response time?

There are popular bench-testing tools such as A/B, wrk, siege, and httpperf that gives summary of the 99th and 95th percentiles. However, their results vary significantly. Sometimes, the percentiles obtained from one tool are 2-3 times bigger compare to another tool.

What is a good way of accurately obtaining the 99th and 95th percentiles while putting the server at its limit?

(I have tried programming my own benchmarking tool in Go. I created multiple threads and fire requests to the server continuously from each thread. However, the context switch wasn't fast enough that the resulting 99th percentile delay is limited by the benchmarking tool, but not the server.)

my backend url not working in yii using webapplicationend

My .htaccess file is like following,

enter code here

RewriteEngine On
RewriteBase /projectroot/
RewriteRule backend backend\.php [T=application/x-httpd-php] 

# Rest of Yii's rewrite rules:
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


# otherwise forward it to index.php
RewriteRule . index.php

In above .htaaccess file my frontend working properly but backend not working... When i click on backend page it goes to frontend one page.